beaglebone.txt 79KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582
  1. #+TITLE: FreedomBone
  2. #+AUTHOR: Bob Mottram
  3. #+EMAIL: bob@robotics.uk.to
  4. #+KEYWORDS: freedombox, debian, beaglebone, friendica, email, web server, home server, internet, censorship, surveillance
  5. #+DESCRIPTION: Turn the Beaglebone Black into a personal communications server
  6. #+BEGIN_CENTER
  7. *How to turn the Beaglebone Black into a FreedomBox-like personal communications server*
  8. #+END_CENTER
  9. #+BEGIN_CENTER
  10. [[[[file:images/freedombone.jpg]]]]
  11. #+END_CENTER
  12. #+BEGIN_CENTER
  13. Copyright (C) 2014 Bob Mottram
  14. Permission is granted to copy, distribute and/or modify this document under the terms of the [[https://gnu.org/licenses/fdl.html][GNU Free Documentation License]], Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
  15. Source for this web site in [[https://en.wikipedia.org/wiki/Org-mode][Emacs org-mode]] format is available [[/beaglebone.txt][here]]. Comments or patches may be submitted via [[https://github.com/fuzzgun/freedombone][Github]].
  16. #+END_CENTER
  17. * Introduction
  18. #+BEGIN_VERSE
  19. /If you look at it from an engineering perspective, an iterative perspective, it’s clear that you have to try something rather than do nothing./
  20. -- Edward J. Snowden
  21. #+END_VERSE
  22. ** What is FreedomBone?
  23. Today many of us rely upon "free" services in the cloud, such as Gmail, Facebook, Google+ and so on. It might appear that these services are indispensible infrastructure of the modern internet, but actually they're not strictly needed and the amount of value which they deliver to the average internet user is very marginal. It is possible to be a citizen of the internet and yet not use those things - to disintermediate the most well known companies and cut out their prurient or merely cringeworthy business models.
  24. FreedomBone is a personal home communications server based upon the BeagleBone Black hardware. It's small and cheap and will allow you to use email, have your own web site and do social networking in a federated way without needing to rely upon any intermediary companies other than your ISP.
  25. ** Do I need any prior knowledge?
  26. In these instructions only a minimal level of familiarity with Linux is assumed. It's assumed that you know the basics of the /nano/ and /emacs/ editors, but it would be simple to also use other editors if you prefer.
  27. ** Why should I do this?
  28. You should consider doing this if you are a freedom-oriented sort of person and you want to maintain sovereignty over your information. Laws in many places in the world consider you to have relinquished any property rights over data which you put onto a server not owned by youself (i.e. owned by a third party, such as Google or Facebook).
  29. If you don't like the idea of having all your communications intercepted and investigated by the Surveillance State then you should consider running a FreedomBone. If your profession involves maintaining confidentiality as an essential feature, such as legal or medical services, counselling, teaching or any sort of activism then you should consider running a FreedomBone.
  30. As Eben Moglen noted in his now famous [[https://www.youtube.com/watch?v=QOEMv0S8AcA]["Freedom in The Cloud"]] talk the simple fact of you keeping your own internet logs (found in the /var/log directory) puts a certain amount of power in your hands and takes it away from parties who would otherwise sell that information without your knowledge or permission to advertisers or other shady outfits who may not have your best interests at heart.
  31. ** After it's installed will it need a lot of maintenance?
  32. So long as the hardware is ok the amount of maintenance needed should be very small. Unlike on Windows based systems you don't need to defragment drives or mess about with anti-virus programs. I ran a similar Sheevaplug system between 2010 and 2013 with only occasional software updates or reboots, and uptime was probably 99% or better.
  33. ** Is it secure?
  34. Nothing is totally secure or infallible. You could have the most secure technology and yet still use easy to guess passwords. This system will not defend you from an attacker who is actively trying to block or corrupt your communications, but I assume that doesn't apply in the majority of cases. Another thing to be aware of is that running a FreedomBone could make you more vulnerable to traffic analysis, since the server is associated with your home address and isn't a giant aggregation of users somewhere in the cloud. You need to weigh this alongside the additional legal protection which owning the server and having it in your own home gives you.
  35. FreedomBone should be far more secure than using popular cloud-based services which have spying built into them as a core feature (although not one which is typically advertised), but it is not necessarily an impenetrable information fortress.
  36. ** Will running a server all the time affect my electricity bill?
  37. Hardly at all. The BeagleBone Black consumes very little power - less than 5W. It would even be potentially possible to run it from a solar panel.
  38. * Inventory
  39. These instructions assume that you have the following ingredients.
  40. ** A BeagleBone Black (BBB)
  41. It should come with a suitable USB cable for the initial setup. To make things look nicer you may also want to get a case for it.
  42. ** An internet connection
  43. It is assumed that the most common situation is via a router installed at home. The router should have ethernet sockets on it and a web interface which allows you to forward ports (sometimes under the "firewall" settings), so that you can forward ssh and web traffic to the BBB.
  44. ** microSD card
  45. To use as the main storage for the BBB. 16 or 32GB is fine, and can be obtained quite cheaply. Try to use Sandisk (class 10 or better) where possible and avoid cheaper cards which often have poor performance.
  46. You may also need an SD card adaptor or USB card reader in order to flash the operating image to the microSD card. For instance, many laptops have an SD card slot but not a microSD slot.
  47. ** 5V/1A power supply
  48. With a plug suitable for powering the BBB. If you have some device with a USB socket nearby you may also be able to just use that for electrical power. However, powering from the USB cable alone might result in crashes when the system is under load, depending upon how many milliamps can be supplied by the USB hub/socket. If the system crashes due to running out of power then you will see that the LEDs on the BBB are continuously on, rather than flashing.
  49. ** An ethernet patch cable
  50. Just an ordinary cat5 or cat6 cable that you can get from most electrical/computer stores.
  51. * Installing Debian onto the microSD card
  52. The Debian Linux OS will be installed onto a small flash drive. It's a good idea to do this rather than using the internal flash, because it will allow you to easily create backups of the entire system if necessary using the dd command.
  53. Download the image.
  54. #+BEGIN_SRC: bash
  55. wget http://freedombone.uk.to/debian-7.2-console-armhf-2013-11-15.tar.xz
  56. #+END_SRC
  57. Verify it.
  58. #+BEGIN_SRC: bash
  59. md5sum debian-7.2-console-armhf-2013-11-15.tar.xz
  60. 0a448f55d14f64c5a7eb3d7cb2c54185 debian-7.2-console-armhf-2013-11-15.tar.xz
  61. #+END_SRC
  62. Uncompress it.
  63. #+BEGIN_SRC: bash
  64. tar xJf debian-7.2-console-armhf-2013-11-15.tar.xz
  65. cd debian-7.2-console-armhf-2013-11-15
  66. #+END_SRC
  67. Create the disk image, where sdX is the name of the flash drive (probably it will be sdb or sdc).
  68. #+BEGIN_SRC: bash
  69. sudo apt-get install u-boot-tools
  70. sudo ./setup_sdcard.sh --mmc /dev/sdX --uboot bone --swap-file 1024
  71. #+END_SRC
  72. Once completed then safely remove the microSD card via your file manager (usually right click and "safely remove" or "eject").
  73. * Setup
  74. #+BEGIN_VERSE
  75. /Build the tools for a future you would want to live in/
  76. -- Kurt Opsahl
  77. #+END_VERSE
  78. ** Things to be aware of
  79. *** A note on ssh
  80. When using ssh to log into the BBB if you get warnings of the type "/the ECDSA host key for domain differs from the key for the IP address/" then run the command:
  81. #+BEGIN_SRC: bash
  82. ssh-keygen -R <IP address>
  83. #+END_SRC
  84. *** Passwords
  85. It's highly recommended that you use a password manager, such as KeepassX, and make all your passwords long random strings. It's also a good idea to use different passwords for different pieces of software, instead of one or two passwords for the whole system. That compartmentalises the security such that even if an attacker gains access to one system they can't necessarily get access to others.
  86. ** Initial
  87. Plug the microSD card into the BBB and Connect the USB cable to your laptop/desktop, then login via ssh.
  88. #+BEGIN_SRC: bash
  89. ssh debian@192.168.7.2
  90. #+END_SRC
  91. The default password is /temppwd/
  92. Then log in as root:
  93. #+BEGIN_SRC: bash
  94. su
  95. #+END_SRC
  96. The default password is /root/
  97. The first thing to do is to change the passwords from their defaults.
  98. #+BEGIN_SRC: bash
  99. passwd
  100. #+END_SRC
  101. Then you will need to change the network interfaces. The main task here is to comment out the stuff related to usb0. That will enable you to plug the BBB into the back of a router and for it to be detectable on the network.
  102. #+BEGIN_SRC: bash
  103. nano /etc/network/interfaces
  104. #+END_SRC
  105. The resulting interfaces file should look like this:
  106. #+BEGIN_SRC: bash
  107. # This file describes the network interfaces available on your system
  108. # and how to activate them. For more information, see interfaces(5).
  109. # The loopback network interface
  110. auto lo
  111. iface lo inet loopback
  112. # The primary network interface
  113. allow-hotplug eth0
  114. iface eth0 inet static
  115. address 192.168.1.60
  116. netmask 255.255.255.0
  117. gateway 192.168.1.254
  118. dns-nameservers 213.73.91.35 85.214.20.141
  119. # Example to keep MAC address between reboots
  120. #hwaddress ether DA:AD:CE:EF:CA:FE
  121. # WiFi Example
  122. #auto wlan0
  123. #iface wlan0 inet dhcp
  124. # wpa-ssid "essid"
  125. # wpa-psk "password"
  126. # Ethernet/RNDIS gadget (g_ether)
  127. # ... or on host side, usbnet and random hwaddr
  128. # Note on some boards, usb0 is automaticly setup with an init script
  129. # in that case, to completely disable remove file [run_boot-scripts] from the boot partition
  130. #iface usb0 inet static
  131. # address 192.168.7.2
  132. # netmask 255.255.255.0
  133. # network 192.168.7.0
  134. # gateway 192.168.7.1
  135. #+END_SRC
  136. CTRL-O followed by ENTER to save, then CTRL-X to exit.
  137. In the above example "address 192.168.1.60" is a static IP address for the BBB, which will allow incoming network traffic to be directed from the router in a reliable manner. It should be outside of the DHCP range set up on the router.
  138. "gateway 192.168.1.254" should be the IP address of the router.
  139. Note that setting the DNS servers with dns-nameservers is important because some home routers do not allow you to change the DNS settings.
  140. Edit resolv.conf.
  141. #+BEGIN_SRC: bash
  142. nano /etc/resolv.conf
  143. #+END_SRC
  144. It should look something like the following:
  145. #+BEGIN_SRC: bash
  146. domain localdomain
  147. search localdomain
  148. nameserver 213.73.91.35
  149. nameserver 85.214.20.141
  150. #+END_SRC
  151. CTRL-O followed by ENTER to save, then CTRL-X to exit.
  152. Now disconnect the BBB from your computer and plug it into the router. You'll need an ethernet patch cable and you may also need a 5V/1A power supply for the BBB.
  153. If you go to the web administration screen for your internet router (often it's on 192.168.2.1 or 192.168.1.254) then after a few minutes you should see the BBB appear on the network. It's name will be "arm".
  154. ** Add a user
  155. Ssh back in to the BBB and login as root. In this example the BBB's IP address is 192.168.1.60.
  156. #+BEGIN_SRC: bash
  157. ssh-keygen -f "/home/myusername/.ssh/known_hosts" -R 192.168.1.60
  158. ssh debian@192.168.1.60
  159. su
  160. #+END_SRC
  161. Then make a new user. It's a bad idea to add users to the sudo group, because that then means that an attacker potentially only needs to know one password in order to get administrator access to the system. With no sudoers an attacker needs to know, or be able to obtain, two separate passwords to be able to really compromise the system.
  162. #+BEGIN_SRC: bash
  163. adduser myusername
  164. #+END_SRC
  165. Exit from the ssh login by typing "exit" a couple of times, then ssh back in as the new user. Make sure you use a difficult to guess password/phrase, or ideally a randomly generated password used together with a password manager such as KeepassX.
  166. Remove the default debian user.
  167. #+BEGIN_SRC: bash
  168. userdel -r debian
  169. #+END_SRC
  170. ** Text editor
  171. For an editor which is less erratic than vi when used within a remote console such as Terminator.
  172. #+BEGIN_SRC: bash
  173. apt-get update
  174. apt-get install emacs
  175. #+END_SRC
  176. ** Alter ssh configuration
  177. Altering the ssh configuration will make it a little more secure than the standard Debian settings.
  178. #+BEGIN_SRC: bash
  179. emacs /etc/ssh/sshd_config
  180. #+END_SRC
  181. Check the following values:
  182. #+BEGIN_SRC: bash
  183. PermitRootLogin no
  184. X11Forwarding no
  185. ServerKeyBits 4096
  186. Protocol 2
  187. PermitEmptyPasswords no
  188. StrictModes yes
  189. #+END_SRC
  190. Append the following:
  191. #+BEGIN_SRC: bash
  192. Ciphers aes256-ctr,aes192-ctr,aes128-ctr
  193. MACs hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
  194. KexAlgorithms diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1
  195. #+END_SRC
  196. CTRL-X CTRL-S to save, then CTRL-X CTRL-C to exit.
  197. #+BEGIN_SRC: bash
  198. service ssh restart
  199. #+END_SRC
  200. To test the new settings log out by typing "exit" a couple of times, then log back in again with:
  201. #+BEGIN_SRC: bash
  202. ssh -vvv myusername@192.168.1.60
  203. #+END_SRC
  204. and check that some number of bits are set within a 4096 bit sized key:
  205. #+BEGIN_SRC: bash
  206. debug2: bits set: */4096
  207. #+END_SRC
  208. ** Set the host name
  209. #+BEGIN_SRC: bash
  210. emacs /etc/hostname
  211. #+END_SRC
  212. CTRL-X CTRL-S to save, then CTRL-X CTRL-C to exit.
  213. also issue the command
  214. #+BEGIN_SRC: bash
  215. hostname /myhostname/
  216. #+END_SRC
  217. You may also need to assign the same hostname separately via your router's web interface.
  218. ** Install NTP
  219. To synchronise time.
  220. #+BEGIN_SRC: bash
  221. apt-get install ntp
  222. #+END_SRC
  223. ** Install fail2ban
  224. #+BEGIN_SRC: bash
  225. apt-get install fail2ban
  226. #+END_SRC
  227. ** Getting onto the web
  228. Create a subdomain on [[http://freedns.afraid.org][freeDNS]]. You may need to click on "/subdomains/" a couple of times. FreeDNS is preferred because it is one of the few domain name providers which supports genuinely free (as in beer) accounts. So if your budget is tiny or non-existent you can still participate as a first class citizen of the internet. If you do have money to spend there is also a premium option.
  229. Select "/dynamic DNS/" then click "/quick cron example/"
  230. An example would look like:
  231. #+BEGIN_SRC: bash
  232. 4,9,14,19,24,29,34,39,44,49,54,59 * * * * root sleep 29 ; wget -O - http://free\ dns.afraid.org/dynamic/update.php?ABCKDNRCLFHENSLKNFEGSBFLFF== >> /\ tmp/freedns_mysubdomain_us_to.log 2>&1 &
  233. #+END_SRC
  234. Edit /etc/crontab and append that to the end of the file.
  235. Via your router's firewall settings you should now open port 22 (secure shell). This will allow you to ssh into your BBB from any location - not just your own local network.
  236. ** install Email
  237. #+BEGIN_VERSE
  238. /If you knew what I know about email, you might not use it/
  239. -- Ladar Levison
  240. #+END_VERSE
  241. Email is not very secure, but its usefulness and ubiquity mean that it's likely to continue as a primary communications method for many years to come. You can encrypt the contents of email using PGP/GPG, but very few people do that and even for those that do the metadata (the From/To/CC/BCC) is always transmitted in the clear as a fundamental aspect of the protocol, allowing an attacker to easily construct detailed models of people's social network and life patterns even without knowing the content.
  242. Exim4 seems much easier to install and configure than Postfix.
  243. #+BEGIN_SRC: bash
  244. aptitude install exim4 sasl2-bin swaks libnet-ssleay-perl
  245. #+END_SRC
  246. You will be prompted to remove postfix. Say yes and yes again.
  247. #+BEGIN_SRC: bash
  248. dpkg-reconfigure exim4-config
  249. #+END_SRC
  250. Settings as follows:
  251. #+BEGIN_SRC: bash
  252. internet site
  253. System mail name: mydomainname.com
  254. IP addresses to listen on: blank
  255. Destinations: mydomainname.com
  256. Domains to relay mail: blank
  257. Smarthost Relay: 192.168.1.0/60 (the range of addresses on your LAN)
  258. Dial on demand = no
  259. Maildir format in home directory
  260. Split configuration = no
  261. Root and postmaster: root email
  262. #+END_SRC
  263. To test the installation:
  264. #+BEGIN_SRC: bash
  265. telnet 192.168.1.60 25
  266. ehlo xxx
  267. quit
  268. #+END_SRC
  269. #+BEGIN_SRC: bash
  270. emacs /etc/default/saslauthd
  271. #+END_SRC
  272. set START=yes then save and exit.
  273. #+BEGIN_SRC: bash
  274. /etc/init.d/saslauthd start
  275. emacs exim-gencert
  276. #+END_SRC
  277. #+BEGIN_SRC: bash
  278. #!/bin/sh -e
  279. if [ -n "$EX4DEBUG" ]; then
  280. echo "now debugging $0 $@"
  281. set -x
  282. fi
  283. DIR=/etc/exim4
  284. CERT=$DIR/exim.crt
  285. KEY=$DIR/exim.key
  286. # This exim binary was built with GnuTLS which does not support dhparams
  287. # from a file. See /usr/share/doc/exim4-base/README.Debian.gz
  288. #DH=$DIR/exim.dhparam
  289. if ! which openssl > /dev/null ;then
  290. echo "$0: openssl is not installed, exiting" 1>&2
  291. exit 1
  292. fi
  293. # valid for ten years
  294. DAYS=3650
  295. if [ "$1" != "--force" ] && [ -f $CERT ] && [ -f $KEY ]; then
  296. echo "[*] $CERT and $KEY exists!"
  297. echo " Use \"$0 --force\" to force generation!"
  298. exit 0
  299. fi
  300. if [ "$1" = "--force" ]; then
  301. shift
  302. fi
  303. #SSLEAY=/tmp/exim.ssleay.$$.cnf
  304. SSLEAY="$(tempfile -m600 -pexi)"
  305. cat > $SSLEAY <<EOM
  306. RANDFILE = $HOME/.rnd
  307. [ req ]
  308. default_bits = 4096
  309. default_keyfile = exim.key
  310. distinguished_name = req_distinguished_name
  311. [ req_distinguished_name ]
  312. countryName = Country Code (2 letters)
  313. countryName_default = GB
  314. countryName_min = 2
  315. countryName_max = 2
  316. stateOrProvinceName = State or Province Name (full name)
  317. localityName = Locality Name (eg, city)
  318. organizationName = Organization Name (eg, company; recommended)
  319. organizationName_max = 64
  320. organizationalUnitName = Organizational Unit Name (eg, section)
  321. organizationalUnitName_max = 64
  322. commonName = Server name (eg. ssl.domain.tld; required!!!)
  323. commonName_max = 64
  324. emailAddress = Email Address
  325. emailAddress_max = 40
  326. EOM
  327. echo "[*] Creating a self signed SSL certificate for Exim!"
  328. echo " This may be sufficient to establish encrypted connections but for"
  329. echo " secure identification you need to buy a real certificate!"
  330. echo " "
  331. echo " Please enter the hostname of your MTA at the Common Name (CN) prompt!"
  332. echo " "
  333. openssl req -config $SSLEAY -x509 -sha256 -newkey rsa:4096 -keyout $KEY -out $CERT -days $DAYS -nodes
  334. #see README.Debian.gz*# openssl dhparam -check -text -5 512 -out $DH
  335. rm -f $SSLEAY
  336. chown root:Debian-exim $KEY $CERT $DH
  337. chmod 640 $KEY $CERT $DH
  338. echo "[*] Done generating self signed certificates for exim!"
  339. echo " Refer to the documentation and example configuration files"
  340. echo " over at /usr/share/doc/exim4-base/ for an idea on how to enable TLS"
  341. echo " support in your mail transfer agent."
  342. #+END_SRC
  343. Save and exit
  344. #+BEGIN_SRC: bash
  345. chmod +x exim-gencert
  346. ./exim-gencert
  347. #+END_SRC
  348. This will generate the certificate used for email authentication. You will be asked for various details, the most important of which is the server name, which should be your domain name.
  349. #+BEGIN_SRC: bash
  350. emacs /etc/exim4/exim4.conf.template
  351. #+END_SRC
  352. Append the following:
  353. #+BEGIN_SRC: bash
  354. login_saslauthd_server:
  355. driver = plaintext
  356. public_name = LOGIN
  357. server_prompts = "Username:: : Password::"
  358. # don't send system passwords over unencrypted connections
  359. server_condition = ${if saslauthd{{$auth1}{$auth2}}{1}{0}}
  360. server_set_id = $auth1
  361. .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
  362. server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
  363. .endif
  364. #+END_SRC
  365. Search for the line *.ifdef MAIN_HARDCODE_PRIMARY_HOSTNAME* and above it insert the line:
  366. #+BEGIN_SRC: bash
  367. MAIN_HARDCODE_PRIMARY_HOSTNAME = mydomainname.com
  368. #+END_SRC
  369. Save and exit.
  370. #+BEGIN_SRC: bash
  371. emacs /etc/exim4/exim4.conf.template
  372. #+END_SRC
  373. Add the line:
  374. #+BEGIN_SRC: bash
  375. MAIN_TLS_ENABLE = true
  376. #+END_SRC
  377. Save and exit.
  378. #+BEGIN_SRC: bash
  379. emacs /etc/default/exim4
  380. change SMTPLISTENEROPTIONS to:
  381. SMTPLISTENEROPTIONS='-oX 465:25 -oP /var/run/exim4/exim.pid'
  382. #+END_SRC
  383. save and exit
  384. #+BEGIN_SRC: bash
  385. emacs /etc/exim4/exim4.conf.template
  386. under the section "main/03_exim4-config_tlsoptions"
  387. Add the following:
  388. tls_on_connect_ports=465
  389. #+END_SRC
  390. save and exit
  391. #+BEGIN_SRC: bash
  392. adduser myusername sasl
  393. addgroup Debian-exim sasl
  394. /etc/init.d/exim4 restart
  395. mkdir /etc/skel/Maildir
  396. #+END_SRC
  397. ** Spam filtering
  398. #+BEGIN_SRC: bash
  399. apt-get install spamassassin exim4-daemon-heavy
  400. emacs /etc/default/spamassassin
  401. #+END_SRC
  402. Set ENABLED=1 then save and exit.
  403. #+BEGIN_SRC: bash
  404. emacs /etc/exim4/exim4.conf.template
  405. #+END_SRC
  406. uncomment or change according to your configuration
  407. #+BEGIN_SRC: bash
  408. # For spam scanning, there is a similar option that defines the interface to
  409. # SpamAssassin. You do not need to set this if you are using the default, which
  410. # is shown in this commented example. As for virus scanning, you must also
  411. # modify the acl_check_data access control list to enable spam scanning.
  412. spamd_address = 127.0.0.1 783
  413. #+END_SRC
  414. add spam header in the /acl_check_data/ section:
  415. #+BEGIN_SRC: bash
  416. ### acl/40_exim4-config_check_data
  417. #################################
  418. # This ACL is used after the contents of a message have been received. This
  419. # is the ACL in which you can test a message's headers or body, and in
  420. # particular, this is where you can invoke external virus or spam scanners.
  421. acl_check_data:
  422. ...
  423. ...
  424. ...
  425. # See the exim docs and the exim wiki for more suitable examples.
  426. #
  427. # warn
  428. # spam = Debian-exim:true
  429. # add_header = X-Spam_score: $spam_score\n\
  430. # X-Spam_score_int: $spam_score_int\n\
  431. # X-Spam_bar: $spam_bar\n\
  432. # X-Spam_report: $spam_report
  433. # put headers in all messages (no matter if spam or not)
  434. warn spam = nobody:true
  435. add_header = X-Spam-Score: $spam_score ($spam_bar)
  436. add_header = X-Spam-Report: $spam_report
  437. # add second subject line with *SPAM* marker when message
  438. # is over threshold
  439. warn spam = nobody
  440. add_header = Subject: ***SPAM (score:$spam_score)*** $h_Subject:
  441. #+END_SRC
  442. Save and exit.
  443. Then restart
  444. #+BEGIN_SRC: bash
  445. exit
  446. emacs ~/.procmailrc
  447. #+END_SRC
  448. The text should look like the following.
  449. #+BEGIN_SRC: sh
  450. MAILDIR=$HOME/Maildir
  451. DEFAULT=$MAILDIR/
  452. LOGFILE=$HOME/log/procmail.log
  453. LOGABSTRACT=all
  454. # get spamassassin to check emails
  455. :0fw: .spamassassin.lock
  456. * < 256000
  457. | spamc
  458. # strong spam are discarded
  459. :0
  460. * ^X-Spam-Level: \*\*\*\*\*\*
  461. /dev/null
  462. # weak spam are kept just in case - clear this out every now and then
  463. :0
  464. * ^X-Spam-Level: \*\*\*\*\*
  465. .0-spam/
  466. # if it wasn't detected as spam, but is to a fake address, then we
  467. # know it is spam, so learn from that
  468. :0
  469. * !^(From|To|cc|bcc)[ :].*($USER|root|webmaster|admin|postmaster).*@acooke\.org
  470. * !^(From|To|cc|bcc)[ :].*@isti\.com
  471. # add mailing lists below
  472. * !^From[ :].*(snowmail_daily@...|Section@...|rforno@...|alert@...).*
  473. {
  474. # save in case of screw-ups, mailing lists, etc
  475. :0 c
  476. .0-spam/
  477. :0
  478. .learn-spam/
  479. }
  480. # otherwise, marginal spam goes here for revision
  481. :0
  482. * ^X-Spam-Level: \*\*
  483. .spam/
  484. #+END_SRC
  485. Save and exit.
  486. #+BEGIN_SRC: bash
  487. su
  488. emacs /usr/bin/filterspam
  489. #+END_SRC
  490. Add the following contents:
  491. #+BEGIN_SRC: bash
  492. #!/bin/bash
  493. USERNAME=$1
  494. MAILDIR=/home/$USERNAME/Maildir/.learn-spam
  495. if [ ! -d "$MAILDIR" ]; then
  496. exit
  497. fi
  498. for f in `ls $MAILDIR/cur`
  499. do
  500. spamc -L spam < "$MAILDIR/cur/$f" > /dev/null
  501. rm "$MAILDIR/cur/$f"
  502. done
  503. for f in `ls $MAILDIR/new`
  504. do
  505. spamc -L spam < "$MAILDIR/new/$f" > /dev/null
  506. rm "$MAILDIR/new/$f"
  507. done
  508. #+END_SRC
  509. Save and exit.
  510. #+BEGIN_SRC: bash
  511. emacs /usr/bin/filterham
  512. #+END_SRC
  513. Add the following contents:
  514. #+BEGIN_SRC: bash
  515. #!/bin/bash
  516. USERNAME=$1
  517. MAILDIR=/home/$USERNAME/Maildir/.learn-ham
  518. if [ ! -d "$MAILDIR" ]; then
  519. exit
  520. fi
  521. for f in `ls $MAILDIR/cur`
  522. do
  523. spamc -L ham < "$MAILDIR/cur/$f" > /dev/null
  524. rm "$MAILDIR/cur/$f"
  525. done
  526. for f in `ls $MAILDIR/new`
  527. do
  528. spamc -L ham < "$MAILDIR/new/$f" > /dev/null
  529. rm "$MAILDIR/new/$f"
  530. done
  531. #+END_SRC
  532. Save and exit.
  533. #+BEGIN_SRC: bash
  534. emacs /etc/crontab
  535. #+END_SRC
  536. Append the following, replacing *myusername* with your username.
  537. #+BEGIN_SRC: bash
  538. */3 * * * * root /usr/bin/filterspam myusername
  539. */3 * * * * root /usr/bin/filterham myusername
  540. #+END_SRC
  541. Save and exit.
  542. #+BEGIN_SRC: bash
  543. chmod 655 /usr/bin/filterspam /usr/bin/filterham
  544. service spamassassin restart
  545. service exim4 restart
  546. service cron restart
  547. #+END_SRC
  548. ** Install dovecot
  549. #+BEGIN_SRC: bash
  550. aptitude -y install dovecot-common dovecot-pop3d dovecot-imapd
  551. #+END_SRC
  552. #+BEGIN_SRC: bash
  553. emacs /etc/dovecot/dovecot.conf
  554. #+END_SRC
  555. # line 26: change ( if not listen IPv6 port )
  556. listen = *
  557. #+BEGIN_SRC: bash
  558. emacs /etc/dovecot/conf.d/10-auth.conf
  559. #+END_SRC
  560. # line 9: uncomment and change ( allow plain text auth )
  561. disable_plaintext_auth = no
  562. # line 99: add
  563. auth_mechanisms = plain login
  564. #+BEGIN_SRC: bash
  565. emacs /etc/dovecot/conf.d/10-mail.conf
  566. #+END_SRC
  567. # line 30: uncomment and add
  568. mail_location = maildir:~/Maildir
  569. #+BEGIN_SRC: bash
  570. service dovecot restart
  571. #+END_SRC
  572. ** Mutt email client
  573. #+BEGIN_SRC: bash
  574. apt-get install mutt lynx abook
  575. exit
  576. mkdir ~/.mutt
  577. echo "text/html; lynx -dump -width=78 -nolist %s | sed ‘s/^ //’; copiousoutput; needsterminal; nametemplate=%s.html" > ~/.mutt/mailcap
  578. #+END_SRC
  579. Save and exit.
  580. #+BEGIN_SRC: bash
  581. su
  582. emacs /etc/Muttrc
  583. #+END_SRC
  584. Append the following:
  585. #+BEGIN_SRC: bash
  586. set mbox_type=Maildir
  587. set folder="~/Maildir"
  588. set mask="!^\\.[^.]"
  589. set mbox="~/Maildir"
  590. set record="+.Sent"
  591. set postponed="+.Drafts"
  592. set spoolfile="~/Maildir"
  593. auto_view text/x-vcard text/html text/enriched
  594. set editor="emacsclient %s"
  595. macro index S "<tag-prefix><save-message>=.learn-spam<enter>" "move to learn-spam"
  596. macro pager S "<save-message>=.learn-spam<enter>" "move to learn-spam"
  597. macro index H "<tag-prefix><copy-message>=.learn-ham<enter>" "copy to learn-ham"
  598. macro pager H "<copy-message>=.learn-ham<enter>" "copy to learn-ham"
  599. #+END_SRC
  600. Save and exit.
  601. #+BEGIN_SRC: bash
  602. emacs /etc/mail/spamassassin/local.cf
  603. #+END_SRC
  604. Uncomment *use_bayes*, *bayes_auto_learn*
  605. Save and exit, then run:
  606. #+BEGIN_SRC: bash
  607. service spamassassin restart
  608. #+END_SRC
  609. Now to add an address book:
  610. #+BEGIN_SRC: bash
  611. emacs ~/.muttrc
  612. #+END_SRC
  613. Append the following:
  614. #+BEGIN_SRC: bash
  615. set alias_file=~/.mutt-alias
  616. source ~/.mutt-alias
  617. set query_command= "abook --mutt-query '%s'"
  618. macro index,pager A "<pipe-message>abook --add-email-quiet<return>" "add the sender address to abook"
  619. #+END_SRC
  620. Then save and exit.
  621. #+BEGIN_SRC: bash
  622. touch ~/.mutt-alias
  623. #+END_SRC
  624. Finally you can then type *mutt* to get access to your email. Hence as a fallback, or if you prefer as the primary way of accessing email, you can ssh into the BBB and use the mutt command line email client. Ssh clients are available for all operating systems, and also you should be reasonably protected from passive surveillance between wherever you are and the BBB (although not between the BBB and the wider internet), which can be useful if you are for example using an Android tablet from a cafe or railway station.
  625. To use the address book system open an email and then to add the sender to the address list press the A key. It will ask you for an alias which may be used the next time you want to send a mail. Alternatively you may just edit the *~/.mutt-alias* file directly to add email addresses.
  626. Some useful keys to know are:
  627. | ESC / | Search for text within message contents |
  628. | "/" | Search for text within headers |
  629. | * | Move to the last message |
  630. | TAB | Move to the next unread message |
  631. | d | Delete a message |
  632. | u | Undelete a mail which is pending deletion |
  633. | $ | Delete all messages selected and check for new messages |
  634. | a | Add to the address book |
  635. | m | Send a new mail |
  636. | S | Mark a message as spam |
  637. | H | Mark a message as ham |
  638. ** K9 email client
  639. *** Incoming server settings
  640. * Select settings/account settings
  641. * Select Fetching mail/incoming server
  642. * Enter your username and password
  643. * IMAP server should be your domain name
  644. * Security: SSL/TLS (always)
  645. * Authentication: Plain
  646. * Port: 993
  647. *** Outgoing (SMTP) server settings
  648. * Select settings/account settings
  649. * Select Sending mail/outgoing server
  650. * Set SMTP server to your domain name
  651. * Set Security to SSL/TLS (always)
  652. * Set port to 465
  653. ** Setting up a web site
  654. Edit the apache configuration so that it doesn't run out of memory if there are a lot of connections.
  655. #+BEGIN_SRC: bash
  656. su
  657. emacs /etc/apache2/apache2.conf
  658. #+END_SRC
  659. Search for MaxClients and replace the value with 20 then save and exit.
  660. In the examples below replace mydomainname.com with your own domain.
  661. #+BEGIN_SRC: bash
  662. export HOSTNAME=mydomainname.com
  663. mkdir /var/www/$HOSTNAME
  664. mkdir /var/www/$HOSTNAME/htdocs
  665. emacs /etc/apache2/sites-available/$HOSTNAME
  666. #+END_SRC
  667. The Apache configuration for the site should look something like the following. Replaye mydonainname with the site domain name.
  668. #+BEGIN_SRC: bash
  669. <VirtualHost *:80>
  670. ServerAdmin myusername@mydomainname.com
  671. ServerName mydomainname.com
  672. DocumentRoot /var/www/mydomainname.com/htdocs
  673. <Directory />
  674. Options FollowSymLinks
  675. AllowOverride All
  676. </Directory>
  677. <Directory /var/www/mydomainname.com/htdocs/>
  678. Options All
  679. AllowOverride All
  680. Order allow,deny
  681. allow from all
  682. </Directory>
  683. # Don't serve .php~ or .php# files created by emacs
  684. <Files ~ "(^#.*#|~|\.sw[op])$">
  685. Order allow,deny
  686. Deny from all
  687. </Files>
  688. <IfModule headers_module>
  689. Header set X-Content-Type-Options nosniff
  690. Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate, private"
  691. Header set Pragma no-cache
  692. </IfModule>
  693. <Files .htaccess>
  694. deny from all
  695. </Files>
  696. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  697. <Directory "/usr/lib/cgi-bin">
  698. AllowOverride All
  699. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  700. Order allow,deny
  701. Allow from all
  702. </Directory>
  703. ErrorLog ${APACHE_LOG_DIR}/error.log
  704. # Possible values include: debug, info, notice, warn, error, crit,
  705. # alert, emerg.
  706. LogLevel warn
  707. CustomLog ${APACHE_LOG_DIR}/access.log combined
  708. </VirtualHost>
  709. <IfModule mod_ssl.c>
  710. <VirtualHost *:443>
  711. ServerAdmin myusername@mydomainname.com
  712. ServerName mydomainname.com
  713. DocumentRoot /var/www/mydomainname.com/htdocs
  714. <Directory />
  715. Options FollowSymLinks
  716. AllowOverride All
  717. </Directory>
  718. <Directory /var/www/mydomainname.com/htdocs/>
  719. Options All
  720. AllowOverride All
  721. Order allow,deny
  722. allow from all
  723. </Directory>
  724. # Don't serve .php~ or .php# files created by emacs
  725. <Files ~ "(^#.*#|~|\.sw[op])$">
  726. Order allow,deny
  727. Deny from all
  728. </Files>
  729. <IfModule headers_module>
  730. Header set X-Content-Type-Options nosniff
  731. Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate, private"
  732. Header set Pragma no-cache
  733. </IfModule>
  734. <Files .htaccess>
  735. deny from all
  736. </Files>
  737. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  738. <Directory "/usr/lib/cgi-bin">
  739. AllowOverride All
  740. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  741. Order allow,deny
  742. Allow from all
  743. </Directory>
  744. ErrorLog ${APACHE_LOG_DIR}/error.log
  745. # Possible values include: debug, info, notice, warn, error, crit,
  746. # alert, emerg.
  747. LogLevel warn
  748. CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
  749. # SSL Engine Switch:
  750. # Enable/Disable SSL for this virtual host.
  751. SSLEngine on
  752. # A self-signed certificate
  753. SSLCertificateFile /etc/ssl/certs/mydomainname.com.crt
  754. SSLCertificateKeyFile /etc/ssl/private/mydomainname.com.key
  755. # Options based on bettercrypto.org
  756. SSLProtocol All -SSLv2 -SSLv3
  757. SSLHonorCipherOrder On
  758. SSLCompression off
  759. SSLCipherSuite EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA
  760. # Add six earth month HSTS header for all users ...
  761. Header add Strict-Transport-Security "max-age=15768000"
  762. # If you want to protect all subdomains , use the following header
  763. # ALL subdomains HAVE TO support https if you use this !
  764. # Strict-Transport-Security: max-age=15768000 ; includeSubDomains
  765. # SSL Engine Options:
  766. # Set various options for the SSL engine.
  767. # o FakeBasicAuth:
  768. # Translate the client X.509 into a Basic Authorisation. This means that
  769. # the standard Auth/DBMAuth methods can be used for access control. The
  770. # user name is the `one line' version of the client's X.509 certificate.
  771. # Note that no password is obtained from the user. Every entry in the user
  772. # file needs this password: `xxj31ZMTZzkVA'.
  773. # o ExportCertData:
  774. # This exports two additional environment variables: SSL_CLIENT_CERT and
  775. # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
  776. # server (always existing) and the client (only existing when client
  777. # authentication is used). This can be used to import the certificates
  778. # into CGI scripts.
  779. # o StdEnvVars:
  780. # This exports the standard SSL/TLS related `SSL_*' environment variables.
  781. # Per default this exportation is switched off for performance reasons,
  782. # because the extraction step is an expensive operation and is usually
  783. # useless for serving static content. So one usually enables the
  784. # exportation for CGI and SSI requests only.
  785. # o StrictRequire:
  786. # This denies access when "SSLRequireSSL" or "SSLRequire" applied even
  787. # under a "Satisfy any" situation, i.e. when it applies access is denied
  788. # and no other module can change it.
  789. # o OptRenegotiate:
  790. # This enables optimized SSL connection renegotiation handling when SSL
  791. # directives are used in per-directory context.
  792. #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
  793. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  794. SSLOptions +StdEnvVars
  795. </FilesMatch>
  796. <Directory /usr/lib/cgi-bin>
  797. SSLOptions +StdEnvVars
  798. </Directory>
  799. # SSL Protocol Adjustments:
  800. # The safe and default but still SSL/TLS standard compliant shutdown
  801. # approach is that mod_ssl sends the close notify alert but doesn't wait for
  802. # the close notify alert from client. When you need a different shutdown
  803. # approach you can use one of the following variables:
  804. # o ssl-unclean-shutdown:
  805. # This forces an unclean shutdown when the connection is closed, i.e. no
  806. # SSL close notify alert is send or allowed to received. This violates
  807. # the SSL/TLS standard but is needed for some brain-dead browsers. Use
  808. # this when you receive I/O errors because of the standard approach where
  809. # mod_ssl sends the close notify alert.
  810. # o ssl-accurate-shutdown:
  811. # This forces an accurate shutdown when the connection is closed, i.e. a
  812. # SSL close notify alert is send and mod_ssl waits for the close notify
  813. # alert of the client. This is 100% SSL/TLS standard compliant, but in
  814. # practice often causes hanging connections with brain-dead browsers. Use
  815. # this only for browsers where you know that their SSL implementation
  816. # works correctly.
  817. # Notice: Most problems of broken clients are also related to the HTTP
  818. # keep-alive facility, so you usually additionally want to disable
  819. # keep-alive for those clients, too. Use variable "nokeepalive" for this.
  820. # Similarly, one has to force some clients to use HTTP/1.0 to workaround
  821. # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
  822. # "force-response-1.0" for this.
  823. BrowserMatch "MSIE [2-6]" \
  824. nokeepalive ssl-unclean-shutdown \
  825. downgrade-1.0 force-response-1.0
  826. # MSIE 7 and newer should be able to use keepalive
  827. BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  828. </VirtualHost>
  829. </IfModule>
  830. #+END_SRC
  831. Then to enable the site:
  832. #+BEGIN_SRC: bash
  833. a2ensite
  834. a2dissite default
  835. a2dissite default-ssl
  836. a2enmod rewrite
  837. a2enmod headers
  838. #+END_SRC
  839. Ensure that "NameVirtualHost *:443" is added to /etc/apache2/ports.conf. It should look something like the following:
  840. #+BEGIN_SRC: bash
  841. NameVirtualHost *:80
  842. Listen 80
  843. <IfModule mod_ssl.c>
  844. NameVirtualHost *:443
  845. Listen 443
  846. </IfModule>
  847. <IfModule mod_gnutls.c>
  848. NameVirtualHost *:443
  849. Listen 443
  850. </IfModule>
  851. #+END_SRC
  852. Create a self-signed certificate. The passphrase isn't important and will be removed, so make it easy (such as "password").
  853. #+BEGIN_SRC: bash
  854. emacs makecert
  855. #+END_SRC
  856. Enter the following:
  857. #+BEGIN_SRC: bash
  858. #!/bin/bash
  859. HOSTNAME=$1
  860. openssl genrsa -des3 -out $HOSTNAME.key 1024
  861. openssl req -new -x509 -nodes -sha1 -days 3650 -key $HOSTNAME.key -out $HOSTNAME.crt
  862. openssl rsa -in $HOSTNAME.key -out $HOSTNAME.new.key
  863. cp $HOSTNAME.new.key $HOSTNAME.key
  864. rm $HOSTNAME.new.key
  865. cp $HOSTNAME.key /etc/ssl/private
  866. chmod 400 /etc/ssl/private/$HOSTNAME.key
  867. cp $HOSTNAME.crt /etc/ssl/certs
  868. shred -zu $HOSTNAME.key $HOSTNAME.crt
  869. a2enmod ssl
  870. service apache2 restart
  871. #+END_SRC
  872. Save and exit.
  873. #+BEGIN_SRC: bash
  874. chmod +x makecert
  875. ./makecert mydomainname.com
  876. #+END_SRC
  877. Enter some trivial password for the key file. The password will be removed as part of the makecert script. Note that leaving a password on the key file would mean that after a power cycle the apache server will not be able to boot properly (it would wait indefinitely for a password to be manually entered) and would look as if it had crashed.
  878. If all has gone well then there should be no warnings or errors after you run the service restart command. After that you should enable ports 80 (HTTP) and 443 (HTTPS) on your internet router/firewall, such that they are redirected to the BBB.
  879. ** Social Networking
  880. #+BEGIN_VERSE
  881. /Facebook is not your friend, it is a surveillance engine./
  882. -- Richard Stallman, Free Software Foundation
  883. #+END_VERSE
  884. *** Friendica
  885. **** Installation
  886. See [[Setting up a web site]] for details of how to update the Apache configuration for your Friendica site.
  887. #+BEGIN_SRC: bash
  888. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  889. #+END_SRC
  890. Enter an admin password for MySQL.
  891. Create a mysql database.
  892. #+BEGIN_SRC: bash
  893. mysql -u root -p
  894. create database friendica;
  895. CREATE USER 'friendicaadmin'@'localhost' IDENTIFIED BY 'password';
  896. GRANT ALL PRIVILEGES ON friendica.* TO 'friendicaadmin'@'localhost';
  897. quit
  898. #+END_SRC
  899. You may need to fix Git SSL problems.
  900. #+BEGIN_SRC: bash
  901. git config --global http.sslVerify true
  902. apt-get install ca-certificates
  903. cd ~/
  904. emacs .gitconfig
  905. #+END_SRC
  906. The .gitconfig file should look something like this:
  907. #+BEGIN_SRC: bash
  908. [http]
  909. sslVerify = true
  910. sslCAinfo = /etc/ssl/certs/ca-certificates.crt
  911. [user]
  912. email = myusername@mydomainname.com
  913. name = yourname
  914. #+END_SRC
  915. Get the source code.
  916. #+BEGIN_SRC: bash
  917. export HOSTNAME=mydomainname.com
  918. cd /var/www/$HOSTNAME
  919. mv htdocs htdocs_old
  920. git clone https://github.com/friendica/friendica.git htdocs
  921. chmod -R 755 htdocs
  922. chown -R www-data:www-data htdocs
  923. chown -R www-data:www-data htdocs/view/smarty3
  924. git clone https://github.com/friendica/friendica-addons.git htdocs/addon
  925. #+END_SRC
  926. Now visit the URL of your site and you should be taken through the rest of the installation procedure. If you have trouble with "allow override" ensure that "AllowOverride" is set to "all" in your Apache settings for the site (within /etc/apache2/sites-available) and then restart the apache2 service.
  927. Install the poller.
  928. #+BEGIN_SRC: bash
  929. emacs /etc/crontab
  930. #+END_SRC
  931. and append the following, changing mydomainname.com to whatever your domain is.
  932. #+BEGIN_SRC: bash
  933. */10 * * * * root cd /var/www/mydomainname.com/htdocs; /usr/bin/php include/poller.php
  934. #+END_SRC
  935. Save and exit, then restart cron.
  936. #+BEGIN_SRC: bash
  937. service cron restart
  938. #+END_SRC
  939. You can improve the speed of Friendica database searches by adding the following indexes:
  940. #+BEGIN_SRC: bash
  941. mysql -u root -p
  942. use friendica;
  943. CREATE INDEX `uri_received` ON item(`uri`, `received`);
  944. CREATE INDEX `received_uri` ON item(`received`, `uri`);
  945. CREATE INDEX `contact-id_created` ON item(`contact-id`, created);
  946. CREATE INDEX `uid_network_received` ON item(`uid`, `network`, `received`);
  947. CREATE INDEX `uid_parent` ON item(`uid`, `parent`);
  948. CREATE INDEX `uid_received` ON item(`uid`, `received`);
  949. CREATE INDEX `uid_network_commented` ON item(`uid`, `network`, `commented`);
  950. CREATE INDEX `uid_title` ON item(uid, `title`);
  951. CREATE INDEX `created_contact-id` ON item(`created`, `contact-id`);
  952. quit
  953. #+END_SRC
  954. **** Backups
  955. Make sure that the database gets backed up. By using cron if anything goes wrong then you should be able to recover the database either from the previous day or the previous week.
  956. #+BEGIN_SRC: bash
  957. emacs /etc/cron.daily/friendicabackup
  958. #+END_SRC
  959. Enter the following
  960. #+BEGIN_SRC: bash
  961. #!/bin/sh
  962. MYSQL_PASSWORD=<mysql root password>
  963. umask 0077
  964. # Backup the database
  965. mysqldump --password=$MYSQL_PASSWORD friendica > /var/backups/friendica_daily.sql
  966. # Make the backup readable only by root
  967. chmod 600 /var/backups/friendica_daily.sql
  968. #+END_SRC
  969. Save and exit.
  970. #+BEGIN_SRC: bash
  971. chmod 600 /etc/cron.daily/friendicabackup
  972. chmod +x /etc/cron.daily/friendicabackup
  973. emacs /etc/cron.weekly/friendicabackup
  974. #+END_SRC
  975. Enter the following
  976. #+BEGIN_SRC: bash
  977. #!/bin/sh
  978. MYSQL_PASSWORD=<mysql root password>
  979. umask 0077
  980. # Backup the database
  981. mysqldump --password=$MYSQL_PASSWORD friendica > /var/backups/friendica_weekly.sql
  982. # Make the backup readable only by root
  983. chmod 600 /var/backups/friendica_weekly.sql
  984. #+END_SRC
  985. Save and exit.
  986. #+BEGIN_SRC: bash
  987. chmod 600 /etc/cron.weekly/friendicabackup
  988. chmod +x /etc/cron.weekly/friendicabackup
  989. #+END_SRC
  990. **** Recommended configuration
  991. ***** Admin
  992. To get to the admin settings you will need to be logged in with the admin email address which you specified at the beginning of the installation procedure. Depending upon the theme which you're using "/admin/" will be available either as an icon or on a drop down menu.
  993. Under the *plugins* section the main one which you may wish to enable is the NSFW plugin. With that enabled if a post contans the #NSFW tag then it will appear minimised by default and you will need to click a button to open it.
  994. Under the *themes* section select a few themes, including mobile themes which are suitable for phones or tablets.
  995. Under the *site* section give your Friendica node a name other than "/my friend network/", you can change the icon and banner text and set the default mobile theme typically to /frost-mobile/. If you don't want your node to host a lot of accounts for people you don't know then you may want to set the register policy to "/requires approval/". For security it's probably a good idea only to host accounts for people who you actually know, rather than random strangers. Also be aware that the Beaglebone does not have a great deal of computational power or bandwidth and will not function well if there are hundreds of users using your node. If you're not federating with Diaspora or other sites then you may wish to select "/only allow Friendica contacts/". That improves the security of the system, since communication between Friendica nodes is always encrypted separately and in addition to the usual SSL encryption layer - which makes life interesting for the Surveillance State and at least keeps those cryptanalysts employed.
  996. It's probably a good idea to enable "/private posts by default for new users/" and also "/don't include post content in email notifications/". Since traditional email isn't a secure system and is easily vulnerable to attack by systems such as [[https://en.wikipedia.org/wiki/XKeyscore][Xkeyscore]].
  997. ***** Settings
  998. Each user has their own customisable settings, typically available either via an icon or by an entry on a drop down menu.
  999. Under *additional features* enable "/richtext editor/", "/post preview/", "/group filter/", "/network filter/", "/edit sent posts/" and "/dislike posts/".
  1000. Under *display settings* select your desktop and mobile themes.
  1001. Once you have connected to enough friends it's also a good idea to use the "/export personal data/" option from here. This will save a file to your local system, which you can import into another friendica node if necessary.
  1002. **** To access from an Android device
  1003. ***** App
  1004. Open a browser on your device and go to https://f-droid.org/ then download and install the F-Droid apk. If you then open F-Droid you can search for and install the Friendica app.
  1005. If you are using a self-signed certificate then at the login screen scroll down to the bottom, select the SSL settings then scroll down and disable SSL certificate checks. You will then be able to log in using https, which at least gives you some protection via the encryption.
  1006. More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
  1007. ***** Mobile Theme
  1008. Another way to access Friendica from a mobile device is to just use the web browser. If you have selected a mobile theme within your settings then when viewing from an Android system the mobile theme will be displayed.
  1009. *** Red Matrix
  1010. **** Introduction
  1011. Red Matrix is the current version of the Friendica social networking system. It's more general than Friendica in that it's designed as a generic communication system based around a protocol called "zot". At the time of writing in early 2014 Red Matrix remains at an alpha stage of development and so it's not advised that you install it unless you're willing to put up with bugs and frustrations. In the large majority of cases it's better to stick with Friendica for now.
  1012. **** Prerequisites
  1013. The main problem with Red Matrix is that in order to install it you will need to have purchased a domain name (i.e. not a FreeDNS subdomain) and a SSL certificate for it.
  1014. You could join some other Red Matrix server, but this suffers from "/The Levison Problem/" in which some goons show up with a gagging order demanding coppies of the SSL private key. In that scenario unless the owner of the server is exceptionally brave users may never be informed that the site has been compromised or that there is interception hardware attached to the server. Joining another server defeats the object of being digitally self-sufficient and raises legal question marks about the ownership of data which you might upload to a server which doesn't belong to you.
  1015. **** Installation
  1016. See [[Setting up a web site]] for details of how to update the Apache configuration for your Red Matrix site.
  1017. #+BEGIN_SRC: bash
  1018. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  1019. #+END_SRC
  1020. Enter an admin password for MySQL.
  1021. Create a mysql database.
  1022. #+BEGIN_SRC: bash
  1023. mysql -u root -p
  1024. create database redmatrix;
  1025. CREATE USER 'redmatrixadmin'@'localhost' IDENTIFIED BY 'password';
  1026. GRANT ALL PRIVILEGES ON redmatrix.* TO 'redmatrixadmin'@'localhost';
  1027. quit
  1028. #+END_SRC
  1029. You may need to fix Git SSL problems.
  1030. #+BEGIN_SRC: bash
  1031. git config --global http.sslVerify true
  1032. apt-get install ca-certificates
  1033. cd ~/
  1034. emacs .gitconfig
  1035. #+END_SRC
  1036. The .gitconfig file should look something like this:
  1037. #+BEGIN_SRC: bash
  1038. [http]
  1039. sslVerify = true
  1040. sslCAinfo = /etc/ssl/certs/ca-certificates.crt
  1041. [user]
  1042. email = myusername@mydomainname.com
  1043. name = yourname
  1044. #+END_SRC
  1045. Get the source code.
  1046. #+BEGIN_SRC: bash
  1047. export HOSTNAME=mydomainname.com
  1048. cd /var/www/$HOSTNAME
  1049. mv htdocs htdocs_old
  1050. git clone https://github.com/friendica/red.git htdocs
  1051. chmod -R 755 htdocs
  1052. chown -R www-data:www-data htdocs
  1053. mkdir htdocs/view/tpl/smarty3
  1054. chmod 777 htdocs/view/tpl
  1055. chmod 777 htdocs/view/tpl/smarty3
  1056. git clone https://github.com/friendica/red-addons.git htdocs/addon
  1057. #+END_SRC
  1058. Now visit the URL of your site and you should be taken through the rest of the installation procedure. Note that this may take a few minutes so don't be concerned if it looks as if it has crashed - just leave it running. If you have trouble with "allow override" ensure that "AllowOverride" is set to "all" in your Apache settings for the site (within /etc/apache2/sites-available) and then restart the apache2 service.
  1059. Install the poller.
  1060. #+BEGIN_SRC
  1061. emacs /etc/crontab
  1062. #+END_SRC
  1063. and append the following, changing mydomainname.com to whatever your domain is.
  1064. #+BEGIN_SRC
  1065. */10 * * * * root cd /var/www/mydomainname.com/htdocs; /usr/bin/php include/poller.php
  1066. #+END_SRC
  1067. Save and exit, then restart cron.
  1068. #+BEGIN_SRC: bash
  1069. service cron restart
  1070. #+END_SRC
  1071. **** Backups
  1072. Make sure that the database gets backed up. By using cron if anything goes wrong then you should be able to recover the database either from the previous day or the previous week.
  1073. #+BEGIN_SRC: bash
  1074. emacs /etc/cron.daily/redmatrixbackup
  1075. #+END_SRC
  1076. Enter the following
  1077. #+BEGIN_SRC: bash
  1078. #!/bin/sh
  1079. MYSQL_PASSWORD=<mysql root password>
  1080. umask 0077
  1081. # Backup the database
  1082. mysqldump --password=$MYSQL_PASSWORD redmatrix > /var/backups/redmatrix_daily.sql
  1083. # Make the backup readable only by root
  1084. chmod 600 /var/backups/redmatrix_daily.sql
  1085. #+END_SRC
  1086. Save and exit.
  1087. #+BEGIN_SRC: bash
  1088. chmod 600 /etc/cron.daily/redmatrixbackup
  1089. chmod +x /etc/cron.daily/redmatrixbackup
  1090. emacs /etc/cron.weekly/redmatrixbackup
  1091. #+END_SRC
  1092. Enter the following
  1093. #+BEGIN_SRC: bash
  1094. #!/bin/sh
  1095. MYSQL_PASSWORD=<mysql root password>
  1096. umask 0077
  1097. # Backup the database
  1098. mysqldump --password=$MYSQL_PASSWORD redmatrix > /var/backups/redmatrix_weekly.sql
  1099. # Make the backup readable only by root
  1100. chmod 600 /var/backups/redmatrix_weekly.sql
  1101. #+END_SRC
  1102. Save and exit.
  1103. #+BEGIN_SRC: bash
  1104. chmod 600 /etc/cron.weekly/redmatrixbackup
  1105. chmod +x /etc/cron.weekly/redmatrixbackup
  1106. #+END_SRC
  1107. **** To access from an Android device
  1108. ***** App
  1109. Open a browser on your device and go to https://f-droid.org/ then download and install the F-Droid apk. If you then open F-Droid you can search for and install the Friendica app.
  1110. If you are using a self-signed certificate then at the login screen scroll down to the bottom, select the SSL settings then scroll down and disable SSL certificate checks. You will then be able to log in using https, which at least gives you some protection via the encryption.
  1111. More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
  1112. ** Install a Blog
  1113. Wordpress is the most popular blogging platform, but in practice I found it to be high maintenance with frequent security updates and breakages. More practical for a home server is Flatpress. Flatpress doesn't use a MySql database, just text files, and so is easy to relocate or reinstall.
  1114. See the [[Setting up a web site]] section of this document for details of how to configure the web server for your blog's domain.
  1115. Download flatpress.
  1116. #+BEGIN_SRC: bash
  1117. wget http://freedombone.uk.to/flatpress.tar.gz
  1118. #+END_SRC
  1119. Verify the download:
  1120. #+BEGIN_SRC: bash
  1121. md5sum flatpress.tar.gz
  1122. 6ad5c230a5cb1ac096ff657f1b138cc7 flatpress.tar.gz
  1123. #+END_SRC
  1124. Extract and install it.
  1125. #+BEGIN_SRC: bash
  1126. tar -xzvf flatpress.tar.gz
  1127. cd flatpress-*
  1128. cp -r * /var/www/$HOSTNAME/htdocs
  1129. rm -rf flatpress-*
  1130. rm -f flatpress.tar.gz
  1131. #+END_SRC
  1132. Now visit your blog and follow the setup instructions, which are quite minimal. Various themes and addons are available from the Flatpress web site, http://www.flatpress.org
  1133. ** Install a VoIP server
  1134. #+BEGIN_VERSE
  1135. /Our core principles, whether in software or sovereignty, have always been about freedom and dignity, for all people, on an equal basis/
  1136. -- David Sugar, GNU Telephony
  1137. #+END_VERSE
  1138. *** The server
  1139. Sipwitch is like an introduction service or phone book for SIP VoIP clients. Once introduced the clients can then talk directly, and this means that sipwitch is very lightweight and can run on low power systems such as the BBB.
  1140. Edit your package sources:
  1141. #+BEGIN_SRC: bash
  1142. emacs /etc/apt/sources.list
  1143. #+END_SRC
  1144. Append the following line:
  1145. #+BEGIN_SRC: bash
  1146. deb http://dev.gnutelephony.org/archive/ wheezy/
  1147. #+END_SRC
  1148. Save and exit.
  1149. To load the repository the first time after adding it to the sources.list, since you do not have the verification keys already installed yet. Then do
  1150. #+BEGIN_SRC: bash
  1151. apt-get install gnutelephony-keyring
  1152. #+END_SRC
  1153. After that it will be happy to accept it as a signed repository. The verification keys can also be directly fetched with
  1154. #+BEGIN_SRC: bash
  1155. wget http://dev.gnutelephony.org/archive/wheezy/public.key
  1156. #+END_SRC
  1157. and manually added instead with
  1158. #+BEGIN_SRC: bash
  1159. apt-key add public.key
  1160. #+END_SRC
  1161. To make sure you have all dependencies, do
  1162. #+BEGIN_SRC: bash
  1163. apt-get update;apt-get dist-upgrade
  1164. #+END_SRC
  1165. Before we install anything, let's inspect what is available to us by using
  1166. #+BEGIN_SRC: bash
  1167. dpkg -l sipwitch
  1168. #+END_SRC
  1169. To see the main application. The columns will indicate if the package is installed, which version and a description of the package. Then do
  1170. #+BEGIN_SRC: bash
  1171. dpkg -l sipwitch-*
  1172. #+END_SRC
  1173. to see available supporting applications and plugins. Again, the columns will indicate if the package is installed, which version and a description of each of these.
  1174. To install only the main application, do
  1175. #+BEGIN_SRC: bash
  1176. apt-get install sipwitch
  1177. #+END_SRC
  1178. and to install all supporting plugins:
  1179. #+BEGIN_SRC: bash
  1180. apt-get install sipwitch-plugin-scripting sipwitch-plugin-subscriber sipwitch-plugin-forward sipwitch-plugin-zeroconf
  1181. #+END_SRC
  1182. Add your user into the sipwitch group
  1183. #+BEGIN_SRC: bash
  1184. groupadd sipwitch
  1185. groupadd sipusers
  1186. usermod -aG sipwitch myusername
  1187. usermod -aG sipusers myusername
  1188. #+END_SRC
  1189. Then edit the configuration
  1190. #+BEGIN_SRC: bash
  1191. emacs /etc/sipwitch.conf
  1192. #+END_SRC
  1193. Change the *mapped* value from 200 to 20, since we don't want to be serving huge numbers of calls.
  1194. Alter the *range* value to 10, since we don't need a large number of extensions. This will mean that exension numbers 200 to 209 are available.
  1195. Do not set the *realm* value, as doing so seems to prevent the server from working.
  1196. Save and exit.
  1197. Create a digest string for your username:
  1198. #+BEGIN_SRC: bash
  1199. sipwitch digest myusername
  1200. #+END_SRC
  1201. Make a note of the resulting string because you're going to use it in the users file you'll now create.
  1202. #+BEGIN_SRC: bash
  1203. export HOSTNAME=mydomainname.com
  1204. touch /etc/sipwitch.d/$HOSTNAME.xml
  1205. chmod 600 /etc/sipwitch.d/$HOSTNAME.xml
  1206. emacs /etc/sipwitch.d/$HOSTNAME.xml
  1207. #+END_SRC
  1208. It should look something like the following:
  1209. #+BEGIN_SRC: bash
  1210. <provision>
  1211. <user id="myusername">
  1212. <digest>yourdigeststring</digest>
  1213. <extension>201</extension>
  1214. <display>Your full name</display>
  1215. </user>
  1216. </provision>
  1217. #+END_SRC
  1218. Save and exit. Now edit the configuration.
  1219. #+BEGIN_SRC: bash
  1220. emacs /etc/default/sipwitch
  1221. #+END_SRC
  1222. Change "desktop" to "server", then save and exit.
  1223. Update the IP settings:
  1224. #+BEGIN_SRC: bash
  1225. iptables -A INPUT -p tcp --dport 5060 -j ACCEPT
  1226. iptables -A INPUT -p udp --dport 5060 -j ACCEPT
  1227. iptables -A INPUT -p tcp --dport 5061 -j ACCEPT
  1228. iptables -A INPUT -p udp --dport 5061 -j ACCEPT
  1229. iptables-save
  1230. #+END_SRC
  1231. Test that it's working:
  1232. #+BEGIN_SRC: bash
  1233. pkill -9 sipw
  1234. sipw -x9 -f
  1235. #+END_SRC
  1236. Then try to register with the server using a SIP client (such as Jitsi). If everything worked then use CTRL-C to exit. Then start the service.
  1237. #+BEGIN_SRC: bash
  1238. service sipwitch start
  1239. #+END_SRC
  1240. *** Clients
  1241. **** Jitsi
  1242. Download the latst version from https://jitsi.org/index.php/Main/Download
  1243. TODO
  1244. **** Twinkle client
  1245. The client should have a user profile as following:
  1246. The "user name" is the xxx id used in the <user id="xxx"> entry of /etc/sipwitch.conf
  1247. The "domain" is the yyy domain in the main config <stack><domain>yyy entry of /etc/sipwitch.conf
  1248. The SIP Authentication should have:
  1249. realm = realm as set in <registry><realm> of /etc/sipwitch.conf
  1250. authentication name = <user id="xx"> entry, same as "User Name" field.
  1251. password = value of <secret>zzz in <user> entry of /etc/sipwitch.conf
  1252. Under security tab, set "Enable ZRTP/SRTP encryption"
  1253. **** Android
  1254. TODO
  1255. CSipSimple?
  1256. ** Install an IRC server
  1257. *** Base install
  1258. IRC is not an especially secure system. For instance, even with the best encryption it's easily possible to imagine IRC-specific cribs which could be used by cryptanalytic systems. However, we'll try to implement it in a manner which will at least give the surveillance aparatus something to ponder over.
  1259. First install some dependencies.
  1260. #+BEGIN_SRC: bash
  1261. apt-get update
  1262. apt-get install build-essential openssl libssl-dev
  1263. #+END_SRC
  1264. Then get the source code for ircd-hybrid.
  1265. #+BEGIN_SRC: bash
  1266. cd /tmp
  1267. mkdir hybrid
  1268. cd hybrid
  1269. apt-get source ircd-hybrid
  1270. #+END_SRC
  1271. Modify the source code to include SSL security.
  1272. #+BEGIN_SRC: bash
  1273. emacs ircd-hybrid-*/debian/rules
  1274. #+END_SRC
  1275. Beneath MAXCLIENTS add the line:
  1276. #+BEGIN_SRC: bash
  1277. USE_OPENSSL = 1
  1278. #+END_SRC
  1279. Then save and exit. Now we can build the debian package for ircd-hybrid and install it.
  1280. #+BEGIN_SRC: bash
  1281. cd ircd-hybrid-*
  1282. dpkg-buildpackage -rfakeroot -uc -b
  1283. cd ..
  1284. dpkg -i ircd-hybrid_*.deb
  1285. #+END_SRC
  1286. Customise the configuration to your system, giving it a name and description. In this example 192.168.1.60 is the static IP address on the BBB on the local network, so change that if necessary.
  1287. #+BEGIN_SRC: bash
  1288. emacs /etc/ircd-hybrid/ircd.conf
  1289. #+END_SRC
  1290. Set *name* to the name of your server, and set a description.
  1291. Set a *network_name* and *network_desc*. The network name should not contain any spaces.
  1292. Set max_clients to 20, or however many you expect that you'll typically need.
  1293. Within the admin section set your *name* and *email*.
  1294. Within the *listen* section set host to your fixed IP address (in the earlier
  1295. sections it was 192.168.1.60).
  1296. Within the *auth* section set user = "*@192.168.1.60" - or whatever the fixed IP address of the BBB is on your network.
  1297. Uncomment the first *connect* section and set the *name* to your domain name, the *host* to 192.168.1.60 and the send/accept passwords to a password which you use to log into the IRC server. Also set the *port* to 6670.
  1298. Save and exit, then restart the IRC server. Open port 6670 on your internet router and forward it to the BBB.
  1299. Ensure that the configuration is only readable by the root user.
  1300. #+BEGIN_SRC: bash
  1301. chmod 600 /etc/ircd-hybrid/ircd.conf
  1302. #+END_SRC
  1303. *** Channel management
  1304. To to install channel management tools.
  1305. #+BEGIN_SRC: bash
  1306. cd /tmp
  1307. wget http://freedombone.uk.to/hybserv_1.9.4-1_armhf.deb
  1308. #+END_SRC
  1309. Verify it.
  1310. #+BEGIN_SRC: bash
  1311. md5sum hybserv_1.9.4-1_armhf.deb
  1312. 5b66551ceabb679bdeda1859d23ca6ac hybserv_1.9.4-1_armhf.deb
  1313. #+END_SRC
  1314. Install it.
  1315. #+BEGIN_SRC: bash
  1316. dpkg -i hybserv_1.9.4-1_armhf.deb
  1317. #+END_SRC
  1318. Edit the configuration.
  1319. Make a md5 version of the password for the IRC server operator.
  1320. #+BEGIN_SRC: bash
  1321. /usr/bin/mkpasswd <myoperatorpassword>
  1322. #+END_SRC
  1323. Edit the ircd-hybrid configuration.
  1324. #+BEGIN_SRC: bash
  1325. emacs /etc/ircd-hybrid/ircd.conf
  1326. #+END_SRC
  1327. Enter the md5 password which you previously created within the /operator/ section. Also change /user/ to:
  1328. #+BEGIN_SRC: bash
  1329. user = "*@*";
  1330. #+END_SRC
  1331. Then save and exit.
  1332. #+BEGIN_SRC: bash
  1333. emacs /etc/hybserv/hybserv.conf
  1334. #+END_SRC
  1335. Change #MD5 PASSWORD HERE# to the md5 operator password created earlier, mydomainname.com to your domain name and mysendacceptpassword to the send/accept password specified within /ircd.conf/.
  1336. #+BEGIN_SRC: bash
  1337. A:mynickname <myemailaddress>
  1338. N:irc.mydomainname.com:Hybrid services
  1339. O:*@*:#MD5 PASSWORD HERE#:root:segj (comment out other Q: lines)
  1340. S:mysendacceptpassword:192.168.1.60:6670 (remove the other two services)
  1341. #+END_SRC
  1342. Also remove the line *#NOT-EDITED#*, then save and exit.
  1343. Now we need to restart the ircd and hybrid server to make things work:
  1344. #+BEGIN_SRC: bash
  1345. service ircd-hybrid restart
  1346. service hybserv start
  1347. #+END_SRC
  1348. *** Usage
  1349. On another computer (not the BBB).
  1350. #+BEGIN_SRC: bash
  1351. sudo apt-get install irssi
  1352. irssi
  1353. #+END_SRC
  1354. Connect to the IRC and identify yourself as an operator. Here /mynetwork/ should be the same as *network_name* specified earlier within /ircd.conf/.
  1355. #+BEGIN_SRC: bash
  1356. /server add -auto -network mynetwork -ssl mydonainname.com 6670 mysendacceptpassword
  1357. /connect mydomainname.com
  1358. /channel add -auto #mychannel mynetwork channelpassword
  1359. /network add -nick mynick mychannel
  1360. /join #mychannel
  1361. /msg -servername chanserv REGISTER #mychannel channelpassword
  1362. /msg -servername chanserv set #mychannel mlock +k channelpassword
  1363. #+END_SRC
  1364. If you edit the irssi config file:
  1365. #+BEGIN_SRC: bash
  1366. emacs ~/.irssi/config
  1367. #+END_SRC
  1368. It should look something like this:
  1369. #+BEGIN_SRC: bash
  1370. {
  1371. address = "mydomainname.com";
  1372. chatnet = "mynetwork";
  1373. port = "6670";
  1374. password = "mysendacceptpassword";
  1375. use_ssl = "yes";
  1376. ssl_verify = "no";
  1377. autoconnect = "yes";
  1378. },
  1379. #+END_SRC
  1380. If you're not using a self-signed certificate (self-signed is the default) then you can set *ssl_verify* to "yes".
  1381. ** Install a Jabber/XMPP server
  1382. *** The Server
  1383. Generate a SSL certificate.
  1384. #+BEGIN_SRC: bash
  1385. openssl ecparam -out /etc/ssl/private/xmpp.pem -name prime256v1
  1386. openssl genpkey -paramfile /etc/ssl/private/xmpp.pem -out /etc/ssl/private/xmpp.key
  1387. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  1388. #+END_SRC
  1389. The above uses a Diffie-Hellman elliptic curve (ECDH P-256) algorithm. It is apparent that amongst crypographers there are differences of opinion about the security of elliptic curves, so if you prefer there is also a more traditional RSA way to generate an SSL certificate:
  1390. #+BEGIN_SRC: bash
  1391. openssl genrsa -out /etc/ssl/private/xmpp.key 4096
  1392. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  1393. #+END_SRC
  1394. Install Prosody.
  1395. #+BEGIN_SRC: bash
  1396. apt-get install prosody
  1397. cp -a /etc/prosody/conf.avail/example.com.cfg.lua /etc/prosody/conf.avail/xmpp.cfg.lua
  1398. emacs /etc/prosody/conf.avail/.cfg.lua
  1399. #+END_SRC
  1400. Change the *VirtualHost* name to your domain name and remove the line below it.
  1401. Set the ssl section to:
  1402. #+BEGIN_SRC: bash
  1403. ssl = {
  1404. key = "/etc/ssl/private/xmpp.key";
  1405. certificate = "/etc/ssl/certs/xmpp.crt";
  1406. }
  1407. #+END_SRC
  1408. Save and exit. Create a symbolic link.
  1409. #+BEGIN_SRC: bash
  1410. ln -sf /etc/prosody/conf.avail/xmpp.cfg.lua /etc/prosody/conf.d/xmpp.cfg.lua
  1411. #+END_SRC
  1412. Add a user. You will be prompted to specify a password. You can repeat the process for as many users as needed.
  1413. #+BEGIN_SRC: bash
  1414. prosodyctl adduser myusername@mydomainname.com
  1415. #+END_SRC
  1416. Restart the server
  1417. #+BEGIN_SRC: bash
  1418. service prosody restart
  1419. #+END_SRC
  1420. On your internet router/firewall open ports 5222 and 5223 and forward them to the BBB.
  1421. It's possible to test that your XMPP server is working at https://xmpp.net. It may take several minutes and you'll get a low score because of the self-signed certificate, but it will at least verify that your server is capable of communicating.
  1422. *** Managing users
  1423. To add a user:
  1424. #+BEGIN_SRC: bash
  1425. prosodyctl adduser myusername@mydomainname.com
  1426. #+END_SRC
  1427. To change a user password:
  1428. #+BEGIN_SRC: bash
  1429. prosodyctl passwd myusername@mydomainname.com
  1430. #+END_SRC
  1431. To remove a user:
  1432. #+BEGIN_SRC: bash
  1433. prosodyctl deluser myusername@mydomainname.com
  1434. #+END_SRC
  1435. Report the status of the XMPP server:
  1436. #+BEGIN_SRC: bash
  1437. prosodyctl status
  1438. #+END_SRC
  1439. *** Using with Ubuntu
  1440. Open *System Settings* and select *Online Accounts*, *Add account* and then *Jabber*.
  1441. Enter your username (myusername@mydomainname.com) and password.
  1442. Click on *Advanced* and make sure that *Encryption required* and *Ignore SSL certificate errors* are checked. Ignoring the certificate errors will allow you to use the self-signed certificate created earlier. Then click *Done* and set your Jabber account and Empathy to *On*.
  1443. *** Using with Android
  1444. Install [[https://f-droid.org/][F-Droid]]
  1445. Search for and install Gibberbot
  1446. From the menu open *Accounts*
  1447. Select *Add account*
  1448. Change the server port from 0 to 5222
  1449. Done
  1450. Accept unknown certificate? Select *Always*
  1451. Go back to the initial screen and then using the menu you can add contacts and begin chatting.
  1452. ** Install Gopher
  1453. Gopher is an old internet protocol which originated a few years before the web and is purely text based. It can be quite fun to build a gopher site and browse the gopherverse. One thing to keep in mind is that there is no security with gopher, so any text transmitted is trivially interceptable by systems such as [[https://en.wikipedia.org/wiki/XKeyscore][Xkeyscore]] or deep packet inspection.
  1454. To set up a gopher server:
  1455. #+BEGIN_SRC: bash
  1456. apt-get install build-essential
  1457. wget http://freedombone.uk.to/geomyidae-current.tgz
  1458. #+END_SRC
  1459. Verify the download:
  1460. #+BEGIN_SRC: bash
  1461. md5sum geomyidae-current.tgz
  1462. 3d8bb8601f37ca953b00fc2445ab5abe geomyidae-current.tgz
  1463. #+END_SRC
  1464. Then extract and install it.
  1465. #+BEGIN_SRC: bash
  1466. tar -xzvf geomyidae-current.tgz
  1467. cd geomyidae-*
  1468. make
  1469. make install
  1470. mkdir -p /var/gopher
  1471. #+END_SRC
  1472. Your content should be placed within /var/gopher with the index page being named index.gph. The Gopher format is very simple - simpler than HTML - so creating pages is not much more difficult than editing a text file.
  1473. #+BEGIN_SRC: bash
  1474. emacs /etc/init.d/gopher
  1475. #+END_SRC
  1476. Enter the following:
  1477. #+BEGIN_SRC: bash
  1478. #! /bin/sh
  1479. ### BEGIN INIT INFO
  1480. # Provides: gopher
  1481. # Required-Start: $remote_fs $syslog
  1482. # Required-Stop: $remote_fs $syslog
  1483. # Default-Start: 2 3 4 5
  1484. # Default-Stop: 0 1 6
  1485. # Short-Description: Gopher daemon
  1486. # Description: Gopher daemon
  1487. ### END INIT INFO
  1488. # Do NOT "set -e"
  1489. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  1490. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  1491. DESC="Gopher daemon"
  1492. NAME=geomyidae
  1493. DAEMON=/usr/bin/$NAME
  1494. DAEMON_ARGS="-l /var/log/geomyidae.log -b /var/gopher -p 70"
  1495. PIDFILE=/var/run/$NAME.pid
  1496. SCRIPTNAME=/etc/init.d/$NAME
  1497. # Exit if the package is not installed
  1498. [ -x "$DAEMON" ] || exit 0
  1499. # Read configuration variable file if it is present
  1500. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  1501. # Load the VERBOSE setting and other rcS variables
  1502. . /lib/init/vars.sh
  1503. # Define LSB log_* functions.
  1504. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
  1505. # and status_of_proc is working.
  1506. . /lib/lsb/init-functions
  1507. #
  1508. # Function that starts the daemon/service
  1509. #
  1510. do_start()
  1511. {
  1512. # Return
  1513. # 0 if daemon has been started
  1514. # 1 if daemon was already running
  1515. # 2 if daemon could not be started
  1516. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
  1517. || return 1
  1518. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
  1519. $DAEMON_ARGS \
  1520. || return 2
  1521. # Add code here, if necessary, that waits for the process to be ready
  1522. # to handle requests from services started subsequently which depend
  1523. # on this one. As a last resort, sleep for some time.
  1524. }
  1525. #
  1526. # Function that stops the daemon/service
  1527. #
  1528. do_stop()
  1529. {
  1530. # Return
  1531. # 0 if daemon has been stopped
  1532. # 1 if daemon was already stopped
  1533. # 2 if daemon could not be stopped
  1534. # other if a failure occurred
  1535. start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
  1536. RETVAL="$?"
  1537. [ "$RETVAL" = 2 ] && return 2
  1538. # Wait for children to finish too if this is a daemon that forks
  1539. # and if the daemon is only ever run from this initscript.
  1540. # If the above conditions are not satisfied then add some other code
  1541. # that waits for the process to drop all resources that could be
  1542. # needed by services started subsequently. A last resort is to
  1543. # sleep for some time.
  1544. start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
  1545. [ "$?" = 2 ] && return 2
  1546. # Many daemons don't delete their pidfiles when they exit.
  1547. rm -f $PIDFILE
  1548. return "$RETVAL"
  1549. }
  1550. #
  1551. # Function that sends a SIGHUP to the daemon/service
  1552. #
  1553. do_reload() {
  1554. #
  1555. # If the daemon can reload its configuration without
  1556. # restarting (for example, when it is sent a SIGHUP),
  1557. # then implement that here.
  1558. #
  1559. start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
  1560. return 0
  1561. }
  1562. case "$1" in
  1563. start)
  1564. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  1565. do_start
  1566. case "$?" in
  1567. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  1568. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  1569. esac
  1570. ;;
  1571. stop)
  1572. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  1573. do_stop
  1574. case "$?" in
  1575. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  1576. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  1577. esac
  1578. ;;
  1579. status)
  1580. status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  1581. ;;
  1582. #reload|force-reload)
  1583. #
  1584. # If do_reload() is not implemented then leave this commented out
  1585. # and leave 'force-reload' as an alias for 'restart'.
  1586. #
  1587. #log_daemon_msg "Reloading $DESC" "$NAME"
  1588. #do_reload
  1589. #log_end_msg $?
  1590. #;;
  1591. restart|force-reload)
  1592. #
  1593. # If the "reload" option is implemented then remove the
  1594. # 'force-reload' alias
  1595. #
  1596. log_daemon_msg "Restarting $DESC" "$NAME"
  1597. do_stop
  1598. case "$?" in
  1599. 0|1)
  1600. do_start
  1601. case "$?" in
  1602. 0) log_end_msg 0 ;;
  1603. 1) log_end_msg 1 ;; # Old process is still running
  1604. *) log_end_msg 1 ;; # Failed to start
  1605. esac
  1606. ;;
  1607. *)
  1608. # Failed to stop
  1609. log_end_msg 1
  1610. ;;
  1611. esac
  1612. ;;
  1613. *)
  1614. #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  1615. echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
  1616. exit 3
  1617. ;;
  1618. esac
  1619. :
  1620. #+END_SRC
  1621. Save and exit. Then start the gopher service.
  1622. #+BEGIN_SRC: bash
  1623. chmod +x /etc/init.d/gopher
  1624. update-rc.d gopher defaults
  1625. service gopher start
  1626. #+END_SRC
  1627. On your internet router change the firewall settings to route port 70 to the BBB, then provided that you have a gopher plugin installed within your browser then you should be able to navigate to your gopher site with:
  1628. #+BEGIN_SRC: bash
  1629. gopher://mydomainname.com
  1630. #+END_SRC
  1631. There is a browser addon for Gopher called "overbite". Installing that should enable you to view your site.
  1632. ** Install a Wiki
  1633. Dokuwiki is based upon flat files, and so is easy to move from one server to another without a lot of database complications.
  1634. Download the wiki.
  1635. #+BEGIN_SRC: bash
  1636. wget http://freedombone.uk.to/dokuwiki.tgz
  1637. #+END_SRC
  1638. Verify it.
  1639. #+BEGIN_SRC: bash
  1640. md5sum dokuwiki.tgz
  1641. 9f35055848429659fd63cda1cfea5a48 dokuwiki.tgz
  1642. #+END_SRC
  1643. Then extract and install it.
  1644. #+BEGIN_SRC: bash
  1645. export HOSTNAME=mywikidomainname.com
  1646. tar -xzvf dokuwiki.tgz
  1647. mv /var/www/$HOSTNAME/htdocs /var/www/$HOSTNAME/htdocs_old
  1648. mv dokuwiki /var/www/$HOSTNAME/htdocs
  1649. #+END_SRC
  1650. Edit the Apache configuration for your wiki site.
  1651. #+BEGIN_SRC: bash
  1652. emacs /etc/apache2/sites-available/$HOSTNAME
  1653. #+END_SRC
  1654. The settings should look something like the following.
  1655. #+BEGIN_SRC: bash
  1656. <VirtualHost *:80>
  1657. ServerAdmin myusername@mywikidomainname.com
  1658. ServerName mydomainname.com
  1659. DocumentRoot /var/www/mywikidomainname.com/htdocs
  1660. <Directory /var/www/mywikidomainname.com/htdocs>
  1661. order deny,allow
  1662. allow from all
  1663. </Directory>
  1664. <LocationMatch "/(data|conf|bin|inc)/">
  1665. order allow,deny
  1666. deny from all
  1667. satisfy all
  1668. </LocationMatch>
  1669. <Directory />
  1670. Options FollowSymLinks
  1671. AllowOverride All
  1672. </Directory>
  1673. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  1674. <Directory "/usr/lib/cgi-bin">
  1675. AllowOverride All
  1676. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  1677. Order allow,deny
  1678. Allow from all
  1679. </Directory>
  1680. ErrorLog ${APACHE_LOG_DIR}/error.log
  1681. # Possible values include: debug, info, notice, warn, error, crit,
  1682. # alert, emerg.
  1683. LogLevel warn
  1684. CustomLog ${APACHE_LOG_DIR}/access.log combined
  1685. </VirtualHost>
  1686. <IfModule mod_ssl.c>
  1687. <VirtualHost *:443>
  1688. ServerAdmin myusername@mywikidomainname.com
  1689. ServerName mywikidomainname.com
  1690. DocumentRoot /var/www/mywikidomainname.com/htdocs
  1691. <Directory /var/www/mywikidomainname.com/htdocs>
  1692. order deny,allow
  1693. allow from all
  1694. </Directory>
  1695. <LocationMatch "/(data|conf|bin|inc)/">
  1696. order allow,deny
  1697. deny from all
  1698. satisfy all
  1699. </LocationMatch>
  1700. <Directory />
  1701. Options FollowSymLinks
  1702. AllowOverride All
  1703. </Directory>
  1704. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  1705. <Directory "/usr/lib/cgi-bin">
  1706. AllowOverride All
  1707. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  1708. Order allow,deny
  1709. Allow from all
  1710. </Directory>
  1711. ErrorLog ${APACHE_LOG_DIR}/error.log
  1712. # Possible values include: debug, info, notice, warn, error, crit,
  1713. # alert, emerg.
  1714. LogLevel warn
  1715. CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
  1716. # SSL Engine Switch:
  1717. # Enable/Disable SSL for this virtual host.
  1718. SSLEngine on
  1719. # A self-signed certificate
  1720. SSLCertificateFile /etc/ssl/certs/mydomainname.com.crt
  1721. SSLCertificateKeyFile /etc/ssl/private/mydomainname.com.key
  1722. # SSL Engine Options:
  1723. # Set various options for the SSL engine.
  1724. # o FakeBasicAuth:
  1725. # Translate the client X.509 into a Basic Authorisation. This means that
  1726. # the standard Auth/DBMAuth methods can be used for access control. The
  1727. # user name is the `one line' version of the client's X.509 certificate.
  1728. # Note that no password is obtained from the user. Every entry in the user
  1729. # file needs this password: `xxj31ZMTZzkVA'.
  1730. # o ExportCertData:
  1731. # This exports two additional environment variables: SSL_CLIENT_CERT and
  1732. # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
  1733. # server (always existing) and the client (only existing when client
  1734. # authentication is used). This can be used to import the certificates
  1735. # into CGI scripts.
  1736. # o StdEnvVars:
  1737. # This exports the standard SSL/TLS related `SSL_*' environment variables.
  1738. # Per default this exportation is switched off for performance reasons,
  1739. # because the extraction step is an expensive operation and is usually
  1740. # useless for serving static content. So one usually enables the
  1741. # exportation for CGI and SSI requests only.
  1742. # o StrictRequire:
  1743. # This denies access when "SSLRequireSSL" or "SSLRequire" applied even
  1744. # under a "Satisfy any" situation, i.e. when it applies access is denied
  1745. # and no other module can change it.
  1746. # o OptRenegotiate:
  1747. # This enables optimized SSL connection renegotiation handling when SSL
  1748. # directives are used in per-directory context.
  1749. #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
  1750. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  1751. SSLOptions +StdEnvVars
  1752. </FilesMatch>
  1753. <Directory /usr/lib/cgi-bin>
  1754. SSLOptions +StdEnvVars
  1755. </Directory>
  1756. # SSL Protocol Adjustments:
  1757. # The safe and default but still SSL/TLS standard compliant shutdown
  1758. # approach is that mod_ssl sends the close notify alert but doesn't wait for
  1759. # the close notify alert from client. When you need a different shutdown
  1760. # approach you can use one of the following variables:
  1761. # o ssl-unclean-shutdown:
  1762. # This forces an unclean shutdown when the connection is closed, i.e. no
  1763. # SSL close notify alert is send or allowed to received. This violates
  1764. # the SSL/TLS standard but is needed for some brain-dead browsers. Use
  1765. # this when you receive I/O errors because of the standard approach where
  1766. # mod_ssl sends the close notify alert.
  1767. # o ssl-accurate-shutdown:
  1768. # This forces an accurate shutdown when the connection is closed, i.e. a
  1769. # SSL close notify alert is send and mod_ssl waits for the close notify
  1770. # alert of the client. This is 100% SSL/TLS standard compliant, but in
  1771. # practice often causes hanging connections with brain-dead browsers. Use
  1772. # this only for browsers where you know that their SSL implementation
  1773. # works correctly.
  1774. # Notice: Most problems of broken clients are also related to the HTTP
  1775. # keep-alive facility, so you usually additionally want to disable
  1776. # keep-alive for those clients, too. Use variable "nokeepalive" for this.
  1777. # Similarly, one has to force some clients to use HTTP/1.0 to workaround
  1778. # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
  1779. # "force-response-1.0" for this.
  1780. BrowserMatch "MSIE [2-6]" \
  1781. nokeepalive ssl-unclean-shutdown \
  1782. downgrade-1.0 force-response-1.0
  1783. # MSIE 7 and newer should be able to use keepalive
  1784. BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  1785. </VirtualHost>
  1786. </IfModule>
  1787. #+END_SRC
  1788. Enable your site with:
  1789. #+BEGIN_SRC: bash
  1790. a2ensite
  1791. #+END_SRC
  1792. then select the domain name and reload.
  1793. #+BEGIN_SRC: bash
  1794. service apache2 reload
  1795. #+END_SRC
  1796. and alter permissions:
  1797. #+BEGIN_SRC: bash
  1798. chmod -R 755 /var/www/$HOSTNAME/htdocs
  1799. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs
  1800. #+END_SRC
  1801. Open a browser and visit http://$HOSTNAME/install.php, then fill out the details. Once everything has been accepted without errors:
  1802. #+BEGIN_SRC: bash
  1803. rm /var/www/$HOSTNAME/htdocs/install.php
  1804. #+END_SRC
  1805. ** Install Owncloud
  1806. First create an apache configuration for your Owncloud site. You will need to create a new subdomain via FreeDNS. See the earlier section on [[Setting up a web site]] for details.
  1807. #+BEGIN_SRC: bash
  1808. emacs /etc/php5/apache2filter/php.ini
  1809. #+END_SRC
  1810. Set the following:
  1811. #+BEGIN_SRC: bash
  1812. post_max_size = 32M
  1813. upload_max_filesize = 32M
  1814. #+END_SRC
  1815. Restart apache.
  1816. #+BEGIN_SRC: bash
  1817. service apache2 restart
  1818. #+END_SRC
  1819. Install some dependencies:
  1820. #+BEGIN_SRC: bash
  1821. apt-get install apache2 php5 php5-gd php-xml-parser php5-intl
  1822. apt-get install php5-sqlite php5-mysql smbclient curl libcurl3 php5-curl
  1823. #+END_SRC
  1824. Download owncloud.
  1825. #+BEGIN_SRC: bash
  1826. cd /tmp
  1827. wget http://freedombone.uk.to/owncloud.tar.bz2
  1828. #+END_SRC
  1829. Verify the download:
  1830. #+BEGIN_SRC: bash
  1831. md5 owncloud.tar.bz2
  1832. f43eabb746b5e339ee70d0a6aaf4a49c
  1833. #+END_SRC
  1834. Extract the archive. This may take a couple of minutes, so don't be alarmed that the system has crashed.
  1835. #+BEGIN_SRC: bash
  1836. export HOSTNAME=myownclouddomainname.com
  1837. tar -xjf owncloud.tar.bz2
  1838. #+END_SRC
  1839. Move the extracted files to your site.
  1840. #+BEGIN_SRC: bash
  1841. cp -r owncloud /var/www/$HOSTNAME
  1842. rm -rf /var/www/$HOSTNAME/htdocs
  1843. mv /var/www/$HOSTNAME/owncloud /var/www/$HOSTNAME/htdocs
  1844. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/
  1845. chmod 775 /var/www/$HOSTNAME/htdocs
  1846. chmod 664 /var/www/$HOSTNAME/htdocs/*
  1847. chmod g+s /var/www/$HOSTNAME/htdocs
  1848. #+END_SRC
  1849. With a web browser visit your domain and enter an administrator username and password.
  1850. ** Install Tripwire
  1851. Tripwire will try to detect any intrusions into your system. It's a good idea to install it after you have installed all of the other programs which you intend to use.
  1852. #+BEGIN_SRC: bash
  1853. apt-get install tripwire
  1854. export HOSTNAME=mydomainname.com
  1855. cd /etc/tripwire
  1856. cp arm-local.key $HOSTNAME-local.key
  1857. cp site.key $HOSTNAME-site.key
  1858. tripwire --init
  1859. tripwire --update-policy --secure-mode low /etc/tripwire/twpol.txt
  1860. tripwire --check --interactive
  1861. #+END_SRC
  1862. you will be asked for two passphrases ("site" and "local"). Make a note of these.
  1863. If you subsequently install any more packages or make configuration changes then update the policy again with:
  1864. #+BEGIN_SRC: bash
  1865. tripwire --update-policy --secure-mode low /etc/tripwire/twpol.txt
  1866. #+END_SRC
  1867. Also, to look for any rootkits.
  1868. #+BEGIN_SRC: bash
  1869. apt-get install rkhunter
  1870. #+END_SRC
  1871. * Router/Firewall ports
  1872. The following ports on your internet router/firewall should be forwarded to the BBB.
  1873. | Protocol | Port/s |
  1874. |----------+------------|
  1875. | Gopher | 70 |
  1876. | HTTP | 80 |
  1877. | HTTPS | 443 |
  1878. | IMAP | 143 |
  1879. | IRC SSL | 6670 |
  1880. | SIP | 5060..5061 |
  1881. | SMTP | 25 |
  1882. | SMTPS | 465 |
  1883. | SSH | 22 |
  1884. | XMPP | 5222..5223 |
  1885. * Hints and Tips
  1886. ** Messaging security
  1887. If you're connected to other friends via Friendica then the preferred way to send private messages is via Friendica's built-in messaging system. This is a lot more convenient than using GPG with ordinary email and yet still provides a similar level of protection from unwarranted interception.
  1888. ** Restrictive/hostile user environments
  1889. If you are typically operating within a restrictive of hostile environment where using ssh is not an option because everything other than web ports are blocked then you may wish to try installing oterm:
  1890. http://www.coralbits.com/oterm/
  1891. https://github.com/davidmoreno/onion
  1892. ** Moving Domains
  1893. If you're moving servers and using a different domain name or path then you can search and replace URLs within files in the following way:
  1894. #+BEGIN_SRC: bash
  1895. find /var/www/mynewdomain/htdocs -type f -exec sed -i 's@myolddomain@mynewdomain@g' {} \;
  1896. #+END_SRC
  1897. ** MySql foo
  1898. *** Backup all databases
  1899. To back up all mysql databases:
  1900. #+BEGIN_SRC: bash
  1901. mysqldump -u root -p --all-databases --events > /var/backups/databasebackup.sql
  1902. #+END_SRC
  1903. *** Restoring a particular mysql database
  1904. To restore yesterday's friendica backup:
  1905. #+BEGIN_SRC: bash
  1906. mysql -D friendica -o < /var/backups/friendica_daily.sql
  1907. #+END_SRC
  1908. To restore yesterday's mediawiki backup:
  1909. #+BEGIN_SRC: bash
  1910. mysql -D wikidb -o < /var/backups/wikidb_daily.sql
  1911. #+END_SRC
  1912. *** Removing mysql server
  1913. If you manage to screw up sql server completely then it can be fully deleted with:
  1914. #+BEGIN_SRC: bash
  1915. ps aux | grep mysql
  1916. #+END_SRC
  1917. and use /kill -9 <pid>/ to kill all mysql processes.
  1918. #+BEGIN_SRC: bash
  1919. apt-get remove --purge mysql\*
  1920. apt-get clean
  1921. updatedb
  1922. #+END_SRC