beaglebone.txt 84KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756
  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. #+BEGIN_VERSE
  655. /I hope we will use the Net to cross barriers and connect cultures./
  656. -- Tim Berners-Lee
  657. #+END_VERSE
  658. Edit the apache configuration so that it doesn't run out of memory if there are a lot of connections.
  659. #+BEGIN_SRC: bash
  660. su
  661. emacs /etc/apache2/apache2.conf
  662. #+END_SRC
  663. Search for MaxClients and replace the value with 20 then save and exit.
  664. In the examples below replace mydomainname.com with your own domain.
  665. #+BEGIN_SRC: bash
  666. export HOSTNAME=mydomainname.com
  667. mkdir /var/www/$HOSTNAME
  668. mkdir /var/www/$HOSTNAME/htdocs
  669. emacs /etc/apache2/sites-available/$HOSTNAME
  670. #+END_SRC
  671. The Apache configuration for the site should look something like the following. Replace /mydonainname.com/ with the site domain name.
  672. #+BEGIN_SRC: bash
  673. <VirtualHost *:80>
  674. ServerAdmin myusername@mydomainname.com
  675. ServerName mydomainname.com
  676. DocumentRoot /var/www/mydomainname.com/htdocs
  677. <Directory />
  678. Options FollowSymLinks
  679. AllowOverride All
  680. </Directory>
  681. <Directory /var/www/mydomainname.com/htdocs/>
  682. Options All
  683. AllowOverride All
  684. Order allow,deny
  685. allow from all
  686. </Directory>
  687. # Don't serve .php~ or .php# files created by emacs
  688. <Files ~ "(^#.*#|~|\.sw[op])$">
  689. Order allow,deny
  690. Deny from all
  691. </Files>
  692. <IfModule headers_module>
  693. Header set X-Content-Type-Options nosniff
  694. Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate, private"
  695. Header set Pragma no-cache
  696. </IfModule>
  697. <Files .htaccess>
  698. deny from all
  699. </Files>
  700. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  701. <Directory "/usr/lib/cgi-bin">
  702. AllowOverride All
  703. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  704. Order allow,deny
  705. Allow from all
  706. </Directory>
  707. ErrorLog ${APACHE_LOG_DIR}/error.log
  708. # Possible values include: debug, info, notice, warn, error, crit,
  709. # alert, emerg.
  710. LogLevel warn
  711. CustomLog ${APACHE_LOG_DIR}/access.log combined
  712. </VirtualHost>
  713. <IfModule mod_ssl.c>
  714. <VirtualHost *:443>
  715. ServerAdmin myusername@mydomainname.com
  716. ServerName mydomainname.com
  717. DocumentRoot /var/www/mydomainname.com/htdocs
  718. <Directory />
  719. Options FollowSymLinks
  720. AllowOverride All
  721. </Directory>
  722. <Directory /var/www/mydomainname.com/htdocs/>
  723. Options All
  724. AllowOverride All
  725. Order allow,deny
  726. allow from all
  727. </Directory>
  728. # Don't serve .php~ or .php# files created by emacs
  729. <Files ~ "(^#.*#|~|\.sw[op])$">
  730. Order allow,deny
  731. Deny from all
  732. </Files>
  733. <IfModule headers_module>
  734. Header set X-Content-Type-Options nosniff
  735. Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate, private"
  736. Header set Pragma no-cache
  737. </IfModule>
  738. <Files .htaccess>
  739. deny from all
  740. </Files>
  741. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  742. <Directory "/usr/lib/cgi-bin">
  743. AllowOverride All
  744. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  745. Order allow,deny
  746. Allow from all
  747. </Directory>
  748. ErrorLog ${APACHE_LOG_DIR}/error.log
  749. # Possible values include: debug, info, notice, warn, error, crit,
  750. # alert, emerg.
  751. LogLevel warn
  752. CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
  753. # SSL Engine Switch:
  754. # Enable/Disable SSL for this virtual host.
  755. SSLEngine on
  756. # A self-signed certificate
  757. SSLCertificateFile /etc/ssl/certs/mydomainname.com.crt
  758. SSLCertificateKeyFile /etc/ssl/private/mydomainname.com.key
  759. # Options based on bettercrypto.org
  760. SSLProtocol All -SSLv2 -SSLv3
  761. SSLHonorCipherOrder On
  762. SSLCompression off
  763. 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
  764. # Add six earth month HSTS header for all users ...
  765. Header add Strict-Transport-Security "max-age=15768000"
  766. # If you want to protect all subdomains , use the following header
  767. # ALL subdomains HAVE TO support https if you use this !
  768. # Strict-Transport-Security: max-age=15768000 ; includeSubDomains
  769. # SSL Engine Options:
  770. # Set various options for the SSL engine.
  771. # o FakeBasicAuth:
  772. # Translate the client X.509 into a Basic Authorisation. This means that
  773. # the standard Auth/DBMAuth methods can be used for access control. The
  774. # user name is the `one line' version of the client's X.509 certificate.
  775. # Note that no password is obtained from the user. Every entry in the user
  776. # file needs this password: `xxj31ZMTZzkVA'.
  777. # o ExportCertData:
  778. # This exports two additional environment variables: SSL_CLIENT_CERT and
  779. # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
  780. # server (always existing) and the client (only existing when client
  781. # authentication is used). This can be used to import the certificates
  782. # into CGI scripts.
  783. # o StdEnvVars:
  784. # This exports the standard SSL/TLS related `SSL_*' environment variables.
  785. # Per default this exportation is switched off for performance reasons,
  786. # because the extraction step is an expensive operation and is usually
  787. # useless for serving static content. So one usually enables the
  788. # exportation for CGI and SSI requests only.
  789. # o StrictRequire:
  790. # This denies access when "SSLRequireSSL" or "SSLRequire" applied even
  791. # under a "Satisfy any" situation, i.e. when it applies access is denied
  792. # and no other module can change it.
  793. # o OptRenegotiate:
  794. # This enables optimized SSL connection renegotiation handling when SSL
  795. # directives are used in per-directory context.
  796. #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
  797. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  798. SSLOptions +StdEnvVars
  799. </FilesMatch>
  800. <Directory /usr/lib/cgi-bin>
  801. SSLOptions +StdEnvVars
  802. </Directory>
  803. # SSL Protocol Adjustments:
  804. # The safe and default but still SSL/TLS standard compliant shutdown
  805. # approach is that mod_ssl sends the close notify alert but doesn't wait for
  806. # the close notify alert from client. When you need a different shutdown
  807. # approach you can use one of the following variables:
  808. # o ssl-unclean-shutdown:
  809. # This forces an unclean shutdown when the connection is closed, i.e. no
  810. # SSL close notify alert is send or allowed to received. This violates
  811. # the SSL/TLS standard but is needed for some brain-dead browsers. Use
  812. # this when you receive I/O errors because of the standard approach where
  813. # mod_ssl sends the close notify alert.
  814. # o ssl-accurate-shutdown:
  815. # This forces an accurate shutdown when the connection is closed, i.e. a
  816. # SSL close notify alert is send and mod_ssl waits for the close notify
  817. # alert of the client. This is 100% SSL/TLS standard compliant, but in
  818. # practice often causes hanging connections with brain-dead browsers. Use
  819. # this only for browsers where you know that their SSL implementation
  820. # works correctly.
  821. # Notice: Most problems of broken clients are also related to the HTTP
  822. # keep-alive facility, so you usually additionally want to disable
  823. # keep-alive for those clients, too. Use variable "nokeepalive" for this.
  824. # Similarly, one has to force some clients to use HTTP/1.0 to workaround
  825. # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
  826. # "force-response-1.0" for this.
  827. BrowserMatch "MSIE [2-6]" \
  828. nokeepalive ssl-unclean-shutdown \
  829. downgrade-1.0 force-response-1.0
  830. # MSIE 7 and newer should be able to use keepalive
  831. BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  832. </VirtualHost>
  833. </IfModule>
  834. #+END_SRC
  835. Then to enable the site:
  836. #+BEGIN_SRC: bash
  837. a2ensite
  838. a2dissite default
  839. a2dissite default-ssl
  840. a2enmod rewrite
  841. a2enmod headers
  842. #+END_SRC
  843. Ensure that "NameVirtualHost *:443" is added to /etc/apache2/ports.conf. It should look something like the following:
  844. #+BEGIN_SRC: bash
  845. NameVirtualHost *:80
  846. Listen 80
  847. <IfModule mod_ssl.c>
  848. NameVirtualHost *:443
  849. Listen 443
  850. </IfModule>
  851. <IfModule mod_gnutls.c>
  852. NameVirtualHost *:443
  853. Listen 443
  854. </IfModule>
  855. #+END_SRC
  856. Create a self-signed certificate. The passphrase isn't important and will be removed, so make it easy (such as "password").
  857. #+BEGIN_SRC: bash
  858. emacs makecert
  859. #+END_SRC
  860. Enter the following:
  861. #+BEGIN_SRC: bash
  862. #!/bin/bash
  863. HOSTNAME=$1
  864. openssl genrsa -des3 -out $HOSTNAME.key 1024
  865. openssl req -new -x509 -nodes -sha1 -days 3650 -key $HOSTNAME.key -out $HOSTNAME.crt
  866. openssl rsa -in $HOSTNAME.key -out $HOSTNAME.new.key
  867. cp $HOSTNAME.new.key $HOSTNAME.key
  868. rm $HOSTNAME.new.key
  869. cp $HOSTNAME.key /etc/ssl/private
  870. chmod 400 /etc/ssl/private/$HOSTNAME.key
  871. cp $HOSTNAME.crt /etc/ssl/certs
  872. shred -zu $HOSTNAME.key $HOSTNAME.crt
  873. a2enmod ssl
  874. service apache2 restart
  875. #+END_SRC
  876. Save and exit.
  877. #+BEGIN_SRC: bash
  878. chmod +x makecert
  879. ./makecert mydomainname.com
  880. #+END_SRC
  881. 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.
  882. 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.
  883. ** Social Networking
  884. #+BEGIN_VERSE
  885. /Facebook is not your friend, it is a surveillance engine./
  886. -- Richard Stallman, Free Software Foundation
  887. #+END_VERSE
  888. *** Friendica
  889. **** Installation
  890. See [[Setting up a web site]] for details of how to update the Apache configuration for your Friendica site.
  891. #+BEGIN_SRC: bash
  892. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  893. #+END_SRC
  894. Enter an admin password for MySQL.
  895. Create a mysql database.
  896. #+BEGIN_SRC: bash
  897. mysql -u root -p
  898. create database friendica;
  899. CREATE USER 'friendicaadmin'@'localhost' IDENTIFIED BY 'password';
  900. GRANT ALL PRIVILEGES ON friendica.* TO 'friendicaadmin'@'localhost';
  901. quit
  902. #+END_SRC
  903. You may need to fix Git SSL problems.
  904. #+BEGIN_SRC: bash
  905. git config --global http.sslVerify true
  906. apt-get install ca-certificates
  907. cd ~/
  908. emacs .gitconfig
  909. #+END_SRC
  910. The .gitconfig file should look something like this:
  911. #+BEGIN_SRC: bash
  912. [http]
  913. sslVerify = true
  914. sslCAinfo = /etc/ssl/certs/ca-certificates.crt
  915. [user]
  916. email = myusername@mydomainname.com
  917. name = yourname
  918. #+END_SRC
  919. Get the source code.
  920. #+BEGIN_SRC: bash
  921. export HOSTNAME=mydomainname.com
  922. cd /var/www/$HOSTNAME
  923. mv htdocs htdocs_old
  924. git clone https://github.com/friendica/friendica.git htdocs
  925. chmod -R 755 htdocs
  926. chown -R www-data:www-data htdocs
  927. chown -R www-data:www-data htdocs/view/smarty3
  928. git clone https://github.com/friendica/friendica-addons.git htdocs/addon
  929. #+END_SRC
  930. 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.
  931. Install the poller.
  932. #+BEGIN_SRC: bash
  933. emacs /etc/crontab
  934. #+END_SRC
  935. and append the following, changing mydomainname.com to whatever your domain is.
  936. #+BEGIN_SRC: bash
  937. */10 * * * * root cd /var/www/mydomainname.com/htdocs; /usr/bin/php include/poller.php
  938. #+END_SRC
  939. Save and exit, then restart cron.
  940. #+BEGIN_SRC: bash
  941. service cron restart
  942. #+END_SRC
  943. You can improve the speed of Friendica database searches by adding the following indexes:
  944. #+BEGIN_SRC: bash
  945. mysql -u root -p
  946. use friendica;
  947. CREATE INDEX `uri_received` ON item(`uri`, `received`);
  948. CREATE INDEX `received_uri` ON item(`received`, `uri`);
  949. CREATE INDEX `contact-id_created` ON item(`contact-id`, created);
  950. CREATE INDEX `uid_network_received` ON item(`uid`, `network`, `received`);
  951. CREATE INDEX `uid_parent` ON item(`uid`, `parent`);
  952. CREATE INDEX `uid_received` ON item(`uid`, `received`);
  953. CREATE INDEX `uid_network_commented` ON item(`uid`, `network`, `commented`);
  954. CREATE INDEX `uid_title` ON item(uid, `title`);
  955. CREATE INDEX `created_contact-id` ON item(`created`, `contact-id`);
  956. quit
  957. #+END_SRC
  958. **** Backups
  959. 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.
  960. #+BEGIN_SRC: bash
  961. emacs /etc/cron.daily/friendicabackup
  962. #+END_SRC
  963. Enter the following
  964. #+BEGIN_SRC: bash
  965. #!/bin/sh
  966. MYSQL_PASSWORD=<mysql root password>
  967. umask 0077
  968. # Backup the database
  969. mysqldump --password=$MYSQL_PASSWORD friendica > /var/backups/friendica_daily.sql
  970. # Make the backup readable only by root
  971. chmod 600 /var/backups/friendica_daily.sql
  972. #+END_SRC
  973. Save and exit.
  974. #+BEGIN_SRC: bash
  975. chmod 600 /etc/cron.daily/friendicabackup
  976. chmod +x /etc/cron.daily/friendicabackup
  977. emacs /etc/cron.weekly/friendicabackup
  978. #+END_SRC
  979. Enter the following
  980. #+BEGIN_SRC: bash
  981. #!/bin/sh
  982. MYSQL_PASSWORD=<mysql root password>
  983. umask 0077
  984. # Backup the database
  985. mysqldump --password=$MYSQL_PASSWORD friendica > /var/backups/friendica_weekly.sql
  986. # Make the backup readable only by root
  987. chmod 600 /var/backups/friendica_weekly.sql
  988. #+END_SRC
  989. Save and exit.
  990. #+BEGIN_SRC: bash
  991. chmod 600 /etc/cron.weekly/friendicabackup
  992. chmod +x /etc/cron.weekly/friendicabackup
  993. #+END_SRC
  994. **** Recommended configuration
  995. ***** Admin
  996. 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.
  997. 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.
  998. Under the *themes* section select a few themes, including mobile themes which are suitable for phones or tablets.
  999. 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.
  1000. 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]].
  1001. ***** Settings
  1002. Each user has their own customisable settings, typically available either via an icon or by an entry on a drop down menu.
  1003. Under *additional features* enable "/richtext editor/", "/post preview/", "/group filter/", "/network filter/", "/edit sent posts/" and "/dislike posts/".
  1004. Under *display settings* select your desktop and mobile themes.
  1005. 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.
  1006. **** To access from an Android device
  1007. ***** App
  1008. 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.
  1009. 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.
  1010. More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
  1011. ***** Mobile Theme
  1012. 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.
  1013. *** Red Matrix
  1014. **** Introduction
  1015. 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.
  1016. **** Prerequisites
  1017. 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.
  1018. 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.
  1019. **** Installation
  1020. See [[Setting up a web site]] for details of how to update the Apache configuration for your Red Matrix site.
  1021. #+BEGIN_SRC: bash
  1022. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  1023. #+END_SRC
  1024. Enter an admin password for MySQL.
  1025. Create a mysql database.
  1026. #+BEGIN_SRC: bash
  1027. mysql -u root -p
  1028. create database redmatrix;
  1029. CREATE USER 'redmatrixadmin'@'localhost' IDENTIFIED BY 'password';
  1030. GRANT ALL PRIVILEGES ON redmatrix.* TO 'redmatrixadmin'@'localhost';
  1031. quit
  1032. #+END_SRC
  1033. You may need to fix Git SSL problems.
  1034. #+BEGIN_SRC: bash
  1035. git config --global http.sslVerify true
  1036. apt-get install ca-certificates
  1037. cd ~/
  1038. emacs .gitconfig
  1039. #+END_SRC
  1040. The .gitconfig file should look something like this:
  1041. #+BEGIN_SRC: bash
  1042. [http]
  1043. sslVerify = true
  1044. sslCAinfo = /etc/ssl/certs/ca-certificates.crt
  1045. [user]
  1046. email = myusername@mydomainname.com
  1047. name = yourname
  1048. #+END_SRC
  1049. Get the source code.
  1050. #+BEGIN_SRC: bash
  1051. export HOSTNAME=mydomainname.com
  1052. cd /var/www/$HOSTNAME
  1053. mv htdocs htdocs_old
  1054. git clone https://github.com/friendica/red.git htdocs
  1055. chmod -R 755 htdocs
  1056. chown -R www-data:www-data htdocs
  1057. mkdir htdocs/view/tpl/smarty3
  1058. chmod 777 htdocs/view/tpl
  1059. chmod 777 htdocs/view/tpl/smarty3
  1060. git clone https://github.com/friendica/red-addons.git htdocs/addon
  1061. #+END_SRC
  1062. 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.
  1063. Install the poller.
  1064. #+BEGIN_SRC
  1065. emacs /etc/crontab
  1066. #+END_SRC
  1067. and append the following, changing mydomainname.com to whatever your domain is.
  1068. #+BEGIN_SRC
  1069. */10 * * * * root cd /var/www/mydomainname.com/htdocs; /usr/bin/php include/poller.php
  1070. #+END_SRC
  1071. Save and exit, then restart cron.
  1072. #+BEGIN_SRC: bash
  1073. service cron restart
  1074. #+END_SRC
  1075. **** Backups
  1076. 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.
  1077. #+BEGIN_SRC: bash
  1078. emacs /etc/cron.daily/redmatrixbackup
  1079. #+END_SRC
  1080. Enter the following
  1081. #+BEGIN_SRC: bash
  1082. #!/bin/sh
  1083. MYSQL_PASSWORD=<mysql root password>
  1084. umask 0077
  1085. # Backup the database
  1086. mysqldump --password=$MYSQL_PASSWORD redmatrix > /var/backups/redmatrix_daily.sql
  1087. # Make the backup readable only by root
  1088. chmod 600 /var/backups/redmatrix_daily.sql
  1089. #+END_SRC
  1090. Save and exit.
  1091. #+BEGIN_SRC: bash
  1092. chmod 600 /etc/cron.daily/redmatrixbackup
  1093. chmod +x /etc/cron.daily/redmatrixbackup
  1094. emacs /etc/cron.weekly/redmatrixbackup
  1095. #+END_SRC
  1096. Enter the following
  1097. #+BEGIN_SRC: bash
  1098. #!/bin/sh
  1099. MYSQL_PASSWORD=<mysql root password>
  1100. umask 0077
  1101. # Backup the database
  1102. mysqldump --password=$MYSQL_PASSWORD redmatrix > /var/backups/redmatrix_weekly.sql
  1103. # Make the backup readable only by root
  1104. chmod 600 /var/backups/redmatrix_weekly.sql
  1105. #+END_SRC
  1106. Save and exit.
  1107. #+BEGIN_SRC: bash
  1108. chmod 600 /etc/cron.weekly/redmatrixbackup
  1109. chmod +x /etc/cron.weekly/redmatrixbackup
  1110. #+END_SRC
  1111. **** To access from an Android device
  1112. ***** App
  1113. 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.
  1114. 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.
  1115. More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
  1116. ** Install a Blog
  1117. 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.
  1118. 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.
  1119. Download flatpress.
  1120. #+BEGIN_SRC: bash
  1121. wget http://freedombone.uk.to/flatpress.tar.gz
  1122. #+END_SRC
  1123. Verify the download:
  1124. #+BEGIN_SRC: bash
  1125. md5sum flatpress.tar.gz
  1126. 6ad5c230a5cb1ac096ff657f1b138cc7 flatpress.tar.gz
  1127. #+END_SRC
  1128. Extract and install it.
  1129. #+BEGIN_SRC: bash
  1130. tar -xzvf flatpress.tar.gz
  1131. cd flatpress-*
  1132. cp -r * /var/www/$HOSTNAME/htdocs
  1133. rm -rf flatpress-*
  1134. rm -f flatpress.tar.gz
  1135. #+END_SRC
  1136. 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
  1137. ** Install a VoIP server
  1138. #+BEGIN_VERSE
  1139. /Our core principles, whether in software or sovereignty, have always been about freedom and dignity, for all people, on an equal basis/
  1140. -- David Sugar, GNU Telephony
  1141. #+END_VERSE
  1142. *** The server
  1143. 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.
  1144. Edit your package sources:
  1145. #+BEGIN_SRC: bash
  1146. emacs /etc/apt/sources.list
  1147. #+END_SRC
  1148. Append the following line:
  1149. #+BEGIN_SRC: bash
  1150. deb http://dev.gnutelephony.org/archive/ wheezy/
  1151. #+END_SRC
  1152. Save and exit.
  1153. 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
  1154. #+BEGIN_SRC: bash
  1155. apt-get install gnutelephony-keyring
  1156. #+END_SRC
  1157. After that it will be happy to accept it as a signed repository. The verification keys can also be directly fetched with
  1158. #+BEGIN_SRC: bash
  1159. wget http://dev.gnutelephony.org/archive/wheezy/public.key
  1160. #+END_SRC
  1161. and manually added instead with
  1162. #+BEGIN_SRC: bash
  1163. apt-key add public.key
  1164. #+END_SRC
  1165. To make sure you have all dependencies, do
  1166. #+BEGIN_SRC: bash
  1167. apt-get update;apt-get dist-upgrade
  1168. #+END_SRC
  1169. Before we install anything, let's inspect what is available to us by using
  1170. #+BEGIN_SRC: bash
  1171. dpkg -l sipwitch
  1172. #+END_SRC
  1173. To see the main application. The columns will indicate if the package is installed, which version and a description of the package. Then do
  1174. #+BEGIN_SRC: bash
  1175. dpkg -l sipwitch-*
  1176. #+END_SRC
  1177. 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.
  1178. To install only the main application, do
  1179. #+BEGIN_SRC: bash
  1180. apt-get install sipwitch
  1181. #+END_SRC
  1182. and to install all supporting plugins:
  1183. #+BEGIN_SRC: bash
  1184. apt-get install sipwitch-plugin-scripting sipwitch-plugin-subscriber sipwitch-plugin-forward sipwitch-plugin-zeroconf
  1185. #+END_SRC
  1186. Add your user into the sipwitch group
  1187. #+BEGIN_SRC: bash
  1188. groupadd sipwitch
  1189. groupadd sipusers
  1190. usermod -aG sipwitch myusername
  1191. usermod -aG sipusers myusername
  1192. #+END_SRC
  1193. Then edit the configuration
  1194. #+BEGIN_SRC: bash
  1195. emacs /etc/sipwitch.conf
  1196. #+END_SRC
  1197. Change the *mapped* value from 200 to 20, since we don't want to be serving huge numbers of calls.
  1198. 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.
  1199. Do not set the *realm* value, as doing so seems to prevent the server from working.
  1200. Save and exit.
  1201. Create a digest string for your username:
  1202. #+BEGIN_SRC: bash
  1203. sipwitch digest myusername
  1204. #+END_SRC
  1205. Make a note of the resulting string because you're going to use it in the users file you'll now create.
  1206. #+BEGIN_SRC: bash
  1207. export HOSTNAME=mydomainname.com
  1208. touch /etc/sipwitch.d/$HOSTNAME.xml
  1209. chmod 600 /etc/sipwitch.d/$HOSTNAME.xml
  1210. emacs /etc/sipwitch.d/$HOSTNAME.xml
  1211. #+END_SRC
  1212. It should look something like the following:
  1213. #+BEGIN_SRC: bash
  1214. <provision>
  1215. <user id="myusername">
  1216. <digest>yourdigeststring</digest>
  1217. <extension>201</extension>
  1218. <display>Your full name</display>
  1219. </user>
  1220. </provision>
  1221. #+END_SRC
  1222. Save and exit. Now edit the configuration.
  1223. #+BEGIN_SRC: bash
  1224. emacs /etc/default/sipwitch
  1225. #+END_SRC
  1226. Change "desktop" to "server", then save and exit.
  1227. Update the IP settings:
  1228. #+BEGIN_SRC: bash
  1229. iptables -A INPUT -p tcp --dport 5060 -j ACCEPT
  1230. iptables -A INPUT -p udp --dport 5060 -j ACCEPT
  1231. iptables -A INPUT -p tcp --dport 5061 -j ACCEPT
  1232. iptables -A INPUT -p udp --dport 5061 -j ACCEPT
  1233. iptables-save
  1234. #+END_SRC
  1235. Test that it's working:
  1236. #+BEGIN_SRC: bash
  1237. pkill -9 sipw
  1238. sipw -x9 -f
  1239. #+END_SRC
  1240. 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.
  1241. #+BEGIN_SRC: bash
  1242. service sipwitch start
  1243. #+END_SRC
  1244. *** Clients
  1245. **** Jitsi
  1246. Download the latst version from https://jitsi.org/index.php/Main/Download
  1247. TODO
  1248. **** Twinkle client
  1249. The client should have a user profile as following:
  1250. The "user name" is the xxx id used in the <user id="xxx"> entry of /etc/sipwitch.conf
  1251. The "domain" is the yyy domain in the main config <stack><domain>yyy entry of /etc/sipwitch.conf
  1252. The SIP Authentication should have:
  1253. realm = realm as set in <registry><realm> of /etc/sipwitch.conf
  1254. authentication name = <user id="xx"> entry, same as "User Name" field.
  1255. password = value of <secret>zzz in <user> entry of /etc/sipwitch.conf
  1256. Under security tab, set "Enable ZRTP/SRTP encryption"
  1257. **** Android
  1258. TODO
  1259. CSipSimple?
  1260. ** Install an IRC server
  1261. *** Base install
  1262. 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.
  1263. First install some dependencies.
  1264. #+BEGIN_SRC: bash
  1265. apt-get update
  1266. apt-get install build-essential openssl libssl-dev
  1267. #+END_SRC
  1268. Then get the source code for ircd-hybrid.
  1269. #+BEGIN_SRC: bash
  1270. cd /tmp
  1271. mkdir hybrid
  1272. cd hybrid
  1273. apt-get source ircd-hybrid
  1274. #+END_SRC
  1275. Modify the source code to include SSL security.
  1276. #+BEGIN_SRC: bash
  1277. emacs ircd-hybrid-*/debian/rules
  1278. #+END_SRC
  1279. Beneath MAXCLIENTS add the line:
  1280. #+BEGIN_SRC: bash
  1281. USE_OPENSSL = 1
  1282. #+END_SRC
  1283. Then save and exit. Now we can build the debian package for ircd-hybrid and install it.
  1284. #+BEGIN_SRC: bash
  1285. cd ircd-hybrid-*
  1286. dpkg-buildpackage -rfakeroot -uc -b
  1287. cd ..
  1288. dpkg -i ircd-hybrid_*.deb
  1289. #+END_SRC
  1290. 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.
  1291. #+BEGIN_SRC: bash
  1292. emacs /etc/ircd-hybrid/ircd.conf
  1293. #+END_SRC
  1294. Set *name* to the name of your server, and set a description.
  1295. Set a *network_name* and *network_desc*. The network name should not contain any spaces.
  1296. Set max_clients to 20, or however many you expect that you'll typically need.
  1297. Within the admin section set your *name* and *email*.
  1298. Within the *listen* section set host to your fixed IP address (in the earlier
  1299. sections it was 192.168.1.60).
  1300. Within the *auth* section set user = "*@192.168.1.60" - or whatever the fixed IP address of the BBB is on your network.
  1301. 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.
  1302. Save and exit, then restart the IRC server. Open port 6670 on your internet router and forward it to the BBB.
  1303. Ensure that the configuration is only readable by the root user.
  1304. #+BEGIN_SRC: bash
  1305. chmod 600 /etc/ircd-hybrid/ircd.conf
  1306. #+END_SRC
  1307. *** Channel management
  1308. To to install channel management tools.
  1309. #+BEGIN_SRC: bash
  1310. cd /tmp
  1311. wget http://freedombone.uk.to/hybserv_1.9.4-1_armhf.deb
  1312. #+END_SRC
  1313. Verify it.
  1314. #+BEGIN_SRC: bash
  1315. md5sum hybserv_1.9.4-1_armhf.deb
  1316. 5b66551ceabb679bdeda1859d23ca6ac hybserv_1.9.4-1_armhf.deb
  1317. #+END_SRC
  1318. Install it.
  1319. #+BEGIN_SRC: bash
  1320. dpkg -i hybserv_1.9.4-1_armhf.deb
  1321. #+END_SRC
  1322. Edit the configuration.
  1323. Make a md5 version of the password for the IRC server operator.
  1324. #+BEGIN_SRC: bash
  1325. /usr/bin/mkpasswd <myoperatorpassword>
  1326. #+END_SRC
  1327. Edit the ircd-hybrid configuration.
  1328. #+BEGIN_SRC: bash
  1329. emacs /etc/ircd-hybrid/ircd.conf
  1330. #+END_SRC
  1331. Enter the md5 password which you previously created within the /operator/ section. Also change /user/ to:
  1332. #+BEGIN_SRC: bash
  1333. user = "*@*";
  1334. #+END_SRC
  1335. Then save and exit.
  1336. #+BEGIN_SRC: bash
  1337. emacs /etc/hybserv/hybserv.conf
  1338. #+END_SRC
  1339. 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/.
  1340. #+BEGIN_SRC: bash
  1341. A:mynickname <myemailaddress>
  1342. N:irc.mydomainname.com:Hybrid services
  1343. O:*@*:#MD5 PASSWORD HERE#:root:segj (comment out other Q: lines)
  1344. S:mysendacceptpassword:192.168.1.60:6670 (remove the other two services)
  1345. #+END_SRC
  1346. Also remove the line *#NOT-EDITED#*, then save and exit.
  1347. Now we need to restart the ircd and hybrid server to make things work:
  1348. #+BEGIN_SRC: bash
  1349. service ircd-hybrid restart
  1350. service hybserv start
  1351. #+END_SRC
  1352. *** Usage
  1353. On another computer (not the BBB).
  1354. #+BEGIN_SRC: bash
  1355. sudo apt-get install irssi
  1356. irssi
  1357. #+END_SRC
  1358. Connect to the IRC and identify yourself as an operator. Here /mynetwork/ should be the same as *network_name* specified earlier within /ircd.conf/.
  1359. #+BEGIN_SRC: bash
  1360. /server add -auto -network mynetwork -ssl mydonainname.com 6670 mysendacceptpassword
  1361. /connect mydomainname.com
  1362. /channel add -auto #mychannel mynetwork channelpassword
  1363. /network add -nick mynick mychannel
  1364. /join #mychannel
  1365. /msg -servername chanserv REGISTER #mychannel channelpassword
  1366. /msg -servername chanserv set #mychannel mlock +k channelpassword
  1367. #+END_SRC
  1368. If you edit the irssi config file:
  1369. #+BEGIN_SRC: bash
  1370. emacs ~/.irssi/config
  1371. #+END_SRC
  1372. It should look something like this:
  1373. #+BEGIN_SRC: bash
  1374. {
  1375. address = "mydomainname.com";
  1376. chatnet = "mynetwork";
  1377. port = "6670";
  1378. password = "mysendacceptpassword";
  1379. use_ssl = "yes";
  1380. ssl_verify = "no";
  1381. autoconnect = "yes";
  1382. },
  1383. #+END_SRC
  1384. If you're not using a self-signed certificate (self-signed is the default) then you can set *ssl_verify* to "yes".
  1385. ** Install a Jabber/XMPP server
  1386. #+BEGIN_VERSE
  1387. /Well heck, it isn’t that hard to write an instant messaging system./
  1388. --Jeremie Miller
  1389. #+END_VERSE
  1390. *** The Server
  1391. Generate a SSL certificate.
  1392. #+BEGIN_SRC: bash
  1393. openssl ecparam -out /etc/ssl/private/xmpp.pem -name prime256v1
  1394. openssl genpkey -paramfile /etc/ssl/private/xmpp.pem -out /etc/ssl/private/xmpp.key
  1395. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  1396. #+END_SRC
  1397. 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:
  1398. #+BEGIN_SRC: bash
  1399. openssl genrsa -out /etc/ssl/private/xmpp.key 4096
  1400. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  1401. #+END_SRC
  1402. Install Prosody.
  1403. #+BEGIN_SRC: bash
  1404. apt-get install prosody
  1405. cp -a /etc/prosody/conf.avail/example.com.cfg.lua /etc/prosody/conf.avail/xmpp.cfg.lua
  1406. emacs /etc/prosody/conf.avail/xmpp.cfg.lua
  1407. #+END_SRC
  1408. Change the *VirtualHost* name to your domain name and remove the line below it.
  1409. Set the ssl section to:
  1410. #+BEGIN_SRC: bash
  1411. ssl = {
  1412. key = "/etc/ssl/private/xmpp.key";
  1413. certificate = "/etc/ssl/certs/xmpp.crt";
  1414. }
  1415. #+END_SRC
  1416. Save and exit. Create a symbolic link.
  1417. #+BEGIN_SRC: bash
  1418. ln -sf /etc/prosody/conf.avail/xmpp.cfg.lua /etc/prosody/conf.d/xmpp.cfg.lua
  1419. #+END_SRC
  1420. Add a user. You will be prompted to specify a password. You can repeat the process for as many users as needed.
  1421. #+BEGIN_SRC: bash
  1422. prosodyctl adduser myusername@mydomainname.com
  1423. #+END_SRC
  1424. Restart the server
  1425. #+BEGIN_SRC: bash
  1426. service prosody restart
  1427. #+END_SRC
  1428. On your internet router/firewall open ports 5222 and 5223 and forward them to the BBB.
  1429. 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.
  1430. *** Managing users
  1431. To add a user:
  1432. #+BEGIN_SRC: bash
  1433. prosodyctl adduser myusername@mydomainname.com
  1434. #+END_SRC
  1435. To change a user password:
  1436. #+BEGIN_SRC: bash
  1437. prosodyctl passwd myusername@mydomainname.com
  1438. #+END_SRC
  1439. To remove a user:
  1440. #+BEGIN_SRC: bash
  1441. prosodyctl deluser myusername@mydomainname.com
  1442. #+END_SRC
  1443. Report the status of the XMPP server:
  1444. #+BEGIN_SRC: bash
  1445. prosodyctl status
  1446. #+END_SRC
  1447. *** Using with Ubuntu
  1448. Open *System Settings* and select *Online Accounts*, *Add account* and then *Jabber*.
  1449. Enter your username (myusername@mydomainname.com) and password.
  1450. 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*.
  1451. *** Using with Android
  1452. Install [[https://f-droid.org/][F-Droid]]
  1453. Search for and install Gibberbot
  1454. From the menu open *Accounts*
  1455. Select *Add account*
  1456. Change the server port from 0 to 5222
  1457. Done
  1458. Accept unknown certificate? Select *Always*
  1459. Go back to the initial screen and then using the menu you can add contacts and begin chatting.
  1460. ** Install Gopher
  1461. 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.
  1462. To set up a gopher server:
  1463. #+BEGIN_SRC: bash
  1464. apt-get install build-essential
  1465. wget http://freedombone.uk.to/geomyidae-current.tgz
  1466. #+END_SRC
  1467. Verify the download:
  1468. #+BEGIN_SRC: bash
  1469. md5sum geomyidae-current.tgz
  1470. 3d8bb8601f37ca953b00fc2445ab5abe geomyidae-current.tgz
  1471. #+END_SRC
  1472. Then extract and install it.
  1473. #+BEGIN_SRC: bash
  1474. tar -xzvf geomyidae-current.tgz
  1475. cd geomyidae-*
  1476. make
  1477. make install
  1478. mkdir -p /var/gopher
  1479. #+END_SRC
  1480. 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.
  1481. #+BEGIN_SRC: bash
  1482. emacs /etc/init.d/gopher
  1483. #+END_SRC
  1484. Enter the following:
  1485. #+BEGIN_SRC: bash
  1486. #! /bin/sh
  1487. ### BEGIN INIT INFO
  1488. # Provides: gopher
  1489. # Required-Start: $remote_fs $syslog
  1490. # Required-Stop: $remote_fs $syslog
  1491. # Default-Start: 2 3 4 5
  1492. # Default-Stop: 0 1 6
  1493. # Short-Description: Gopher daemon
  1494. # Description: Gopher daemon
  1495. ### END INIT INFO
  1496. # Do NOT "set -e"
  1497. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  1498. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  1499. DESC="Gopher daemon"
  1500. NAME=geomyidae
  1501. DAEMON=/usr/bin/$NAME
  1502. DAEMON_ARGS="-l /var/log/geomyidae.log -b /var/gopher -p 70"
  1503. PIDFILE=/var/run/$NAME.pid
  1504. SCRIPTNAME=/etc/init.d/$NAME
  1505. # Exit if the package is not installed
  1506. [ -x "$DAEMON" ] || exit 0
  1507. # Read configuration variable file if it is present
  1508. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  1509. # Load the VERBOSE setting and other rcS variables
  1510. . /lib/init/vars.sh
  1511. # Define LSB log_* functions.
  1512. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
  1513. # and status_of_proc is working.
  1514. . /lib/lsb/init-functions
  1515. #
  1516. # Function that starts the daemon/service
  1517. #
  1518. do_start()
  1519. {
  1520. # Return
  1521. # 0 if daemon has been started
  1522. # 1 if daemon was already running
  1523. # 2 if daemon could not be started
  1524. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
  1525. || return 1
  1526. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
  1527. $DAEMON_ARGS \
  1528. || return 2
  1529. # Add code here, if necessary, that waits for the process to be ready
  1530. # to handle requests from services started subsequently which depend
  1531. # on this one. As a last resort, sleep for some time.
  1532. }
  1533. #
  1534. # Function that stops the daemon/service
  1535. #
  1536. do_stop()
  1537. {
  1538. # Return
  1539. # 0 if daemon has been stopped
  1540. # 1 if daemon was already stopped
  1541. # 2 if daemon could not be stopped
  1542. # other if a failure occurred
  1543. start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
  1544. RETVAL="$?"
  1545. [ "$RETVAL" = 2 ] && return 2
  1546. # Wait for children to finish too if this is a daemon that forks
  1547. # and if the daemon is only ever run from this initscript.
  1548. # If the above conditions are not satisfied then add some other code
  1549. # that waits for the process to drop all resources that could be
  1550. # needed by services started subsequently. A last resort is to
  1551. # sleep for some time.
  1552. start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
  1553. [ "$?" = 2 ] && return 2
  1554. # Many daemons don't delete their pidfiles when they exit.
  1555. rm -f $PIDFILE
  1556. return "$RETVAL"
  1557. }
  1558. #
  1559. # Function that sends a SIGHUP to the daemon/service
  1560. #
  1561. do_reload() {
  1562. #
  1563. # If the daemon can reload its configuration without
  1564. # restarting (for example, when it is sent a SIGHUP),
  1565. # then implement that here.
  1566. #
  1567. start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
  1568. return 0
  1569. }
  1570. case "$1" in
  1571. start)
  1572. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  1573. do_start
  1574. case "$?" in
  1575. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  1576. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  1577. esac
  1578. ;;
  1579. stop)
  1580. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  1581. do_stop
  1582. case "$?" in
  1583. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  1584. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  1585. esac
  1586. ;;
  1587. status)
  1588. status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  1589. ;;
  1590. #reload|force-reload)
  1591. #
  1592. # If do_reload() is not implemented then leave this commented out
  1593. # and leave 'force-reload' as an alias for 'restart'.
  1594. #
  1595. #log_daemon_msg "Reloading $DESC" "$NAME"
  1596. #do_reload
  1597. #log_end_msg $?
  1598. #;;
  1599. restart|force-reload)
  1600. #
  1601. # If the "reload" option is implemented then remove the
  1602. # 'force-reload' alias
  1603. #
  1604. log_daemon_msg "Restarting $DESC" "$NAME"
  1605. do_stop
  1606. case "$?" in
  1607. 0|1)
  1608. do_start
  1609. case "$?" in
  1610. 0) log_end_msg 0 ;;
  1611. 1) log_end_msg 1 ;; # Old process is still running
  1612. *) log_end_msg 1 ;; # Failed to start
  1613. esac
  1614. ;;
  1615. *)
  1616. # Failed to stop
  1617. log_end_msg 1
  1618. ;;
  1619. esac
  1620. ;;
  1621. *)
  1622. #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  1623. echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
  1624. exit 3
  1625. ;;
  1626. esac
  1627. :
  1628. #+END_SRC
  1629. Save and exit. Then start the gopher service.
  1630. #+BEGIN_SRC: bash
  1631. chmod +x /etc/init.d/gopher
  1632. update-rc.d gopher defaults
  1633. service gopher start
  1634. #+END_SRC
  1635. 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:
  1636. #+BEGIN_SRC: bash
  1637. gopher://mydomainname.com
  1638. #+END_SRC
  1639. There is a browser addon for Gopher called "overbite". Installing that should enable you to view your site.
  1640. ** Install a Wiki
  1641. Dokuwiki is based upon flat files, and so is easy to move from one server to another without a lot of database complications.
  1642. Download the wiki.
  1643. #+BEGIN_SRC: bash
  1644. wget http://freedombone.uk.to/dokuwiki.tgz
  1645. #+END_SRC
  1646. Verify it.
  1647. #+BEGIN_SRC: bash
  1648. md5sum dokuwiki.tgz
  1649. 9f35055848429659fd63cda1cfea5a48 dokuwiki.tgz
  1650. #+END_SRC
  1651. Then extract and install it.
  1652. #+BEGIN_SRC: bash
  1653. export HOSTNAME=mywikidomainname.com
  1654. tar -xzvf dokuwiki.tgz
  1655. mv /var/www/$HOSTNAME/htdocs /var/www/$HOSTNAME/htdocs_old
  1656. mv dokuwiki /var/www/$HOSTNAME/htdocs
  1657. #+END_SRC
  1658. Edit the Apache configuration for your wiki site.
  1659. #+BEGIN_SRC: bash
  1660. emacs /etc/apache2/sites-available/$HOSTNAME
  1661. #+END_SRC
  1662. The settings should look something like the following.
  1663. #+BEGIN_SRC: bash
  1664. <VirtualHost *:80>
  1665. ServerAdmin myusername@mywikidomainname.com
  1666. ServerName mydomainname.com
  1667. DocumentRoot /var/www/mywikidomainname.com/htdocs
  1668. <Directory /var/www/mywikidomainname.com/htdocs>
  1669. order deny,allow
  1670. allow from all
  1671. </Directory>
  1672. <LocationMatch "/(data|conf|bin|inc)/">
  1673. order allow,deny
  1674. deny from all
  1675. satisfy all
  1676. </LocationMatch>
  1677. <Directory />
  1678. Options FollowSymLinks
  1679. AllowOverride All
  1680. </Directory>
  1681. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  1682. <Directory "/usr/lib/cgi-bin">
  1683. AllowOverride All
  1684. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  1685. Order allow,deny
  1686. Allow from all
  1687. </Directory>
  1688. ErrorLog ${APACHE_LOG_DIR}/error.log
  1689. # Possible values include: debug, info, notice, warn, error, crit,
  1690. # alert, emerg.
  1691. LogLevel warn
  1692. CustomLog ${APACHE_LOG_DIR}/access.log combined
  1693. </VirtualHost>
  1694. <IfModule mod_ssl.c>
  1695. <VirtualHost *:443>
  1696. ServerAdmin myusername@mywikidomainname.com
  1697. ServerName mywikidomainname.com
  1698. DocumentRoot /var/www/mywikidomainname.com/htdocs
  1699. <Directory /var/www/mywikidomainname.com/htdocs>
  1700. order deny,allow
  1701. allow from all
  1702. </Directory>
  1703. <LocationMatch "/(data|conf|bin|inc)/">
  1704. order allow,deny
  1705. deny from all
  1706. satisfy all
  1707. </LocationMatch>
  1708. <Directory />
  1709. Options FollowSymLinks
  1710. AllowOverride All
  1711. </Directory>
  1712. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  1713. <Directory "/usr/lib/cgi-bin">
  1714. AllowOverride All
  1715. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  1716. Order allow,deny
  1717. Allow from all
  1718. </Directory>
  1719. ErrorLog ${APACHE_LOG_DIR}/error.log
  1720. # Possible values include: debug, info, notice, warn, error, crit,
  1721. # alert, emerg.
  1722. LogLevel warn
  1723. CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
  1724. # SSL Engine Switch:
  1725. # Enable/Disable SSL for this virtual host.
  1726. SSLEngine on
  1727. # A self-signed certificate
  1728. SSLCertificateFile /etc/ssl/certs/mydomainname.com.crt
  1729. SSLCertificateKeyFile /etc/ssl/private/mydomainname.com.key
  1730. # Options based on bettercrypto.org
  1731. SSLProtocol All -SSLv2 -SSLv3
  1732. SSLHonorCipherOrder On
  1733. SSLCompression off
  1734. 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
  1735. # SSL Engine Options:
  1736. # Set various options for the SSL engine.
  1737. # o FakeBasicAuth:
  1738. # Translate the client X.509 into a Basic Authorisation. This means that
  1739. # the standard Auth/DBMAuth methods can be used for access control. The
  1740. # user name is the `one line' version of the client's X.509 certificate.
  1741. # Note that no password is obtained from the user. Every entry in the user
  1742. # file needs this password: `xxj31ZMTZzkVA'.
  1743. # o ExportCertData:
  1744. # This exports two additional environment variables: SSL_CLIENT_CERT and
  1745. # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
  1746. # server (always existing) and the client (only existing when client
  1747. # authentication is used). This can be used to import the certificates
  1748. # into CGI scripts.
  1749. # o StdEnvVars:
  1750. # This exports the standard SSL/TLS related `SSL_*' environment variables.
  1751. # Per default this exportation is switched off for performance reasons,
  1752. # because the extraction step is an expensive operation and is usually
  1753. # useless for serving static content. So one usually enables the
  1754. # exportation for CGI and SSI requests only.
  1755. # o StrictRequire:
  1756. # This denies access when "SSLRequireSSL" or "SSLRequire" applied even
  1757. # under a "Satisfy any" situation, i.e. when it applies access is denied
  1758. # and no other module can change it.
  1759. # o OptRenegotiate:
  1760. # This enables optimized SSL connection renegotiation handling when SSL
  1761. # directives are used in per-directory context.
  1762. #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
  1763. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  1764. SSLOptions +StdEnvVars
  1765. </FilesMatch>
  1766. <Directory /usr/lib/cgi-bin>
  1767. SSLOptions +StdEnvVars
  1768. </Directory>
  1769. # SSL Protocol Adjustments:
  1770. # The safe and default but still SSL/TLS standard compliant shutdown
  1771. # approach is that mod_ssl sends the close notify alert but doesn't wait for
  1772. # the close notify alert from client. When you need a different shutdown
  1773. # approach you can use one of the following variables:
  1774. # o ssl-unclean-shutdown:
  1775. # This forces an unclean shutdown when the connection is closed, i.e. no
  1776. # SSL close notify alert is send or allowed to received. This violates
  1777. # the SSL/TLS standard but is needed for some brain-dead browsers. Use
  1778. # this when you receive I/O errors because of the standard approach where
  1779. # mod_ssl sends the close notify alert.
  1780. # o ssl-accurate-shutdown:
  1781. # This forces an accurate shutdown when the connection is closed, i.e. a
  1782. # SSL close notify alert is send and mod_ssl waits for the close notify
  1783. # alert of the client. This is 100% SSL/TLS standard compliant, but in
  1784. # practice often causes hanging connections with brain-dead browsers. Use
  1785. # this only for browsers where you know that their SSL implementation
  1786. # works correctly.
  1787. # Notice: Most problems of broken clients are also related to the HTTP
  1788. # keep-alive facility, so you usually additionally want to disable
  1789. # keep-alive for those clients, too. Use variable "nokeepalive" for this.
  1790. # Similarly, one has to force some clients to use HTTP/1.0 to workaround
  1791. # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
  1792. # "force-response-1.0" for this.
  1793. BrowserMatch "MSIE [2-6]" \
  1794. nokeepalive ssl-unclean-shutdown \
  1795. downgrade-1.0 force-response-1.0
  1796. # MSIE 7 and newer should be able to use keepalive
  1797. BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  1798. </VirtualHost>
  1799. </IfModule>
  1800. #+END_SRC
  1801. Enable your site with:
  1802. #+BEGIN_SRC: bash
  1803. a2ensite
  1804. #+END_SRC
  1805. then select the domain name and reload.
  1806. #+BEGIN_SRC: bash
  1807. service apache2 reload
  1808. #+END_SRC
  1809. and alter permissions:
  1810. #+BEGIN_SRC: bash
  1811. chmod -R 755 /var/www/$HOSTNAME/htdocs
  1812. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs
  1813. #+END_SRC
  1814. Open a browser and visit http://$HOSTNAME/install.php, then fill out the details. Once everything has been accepted without errors:
  1815. #+BEGIN_SRC: bash
  1816. rm /var/www/$HOSTNAME/htdocs/install.php
  1817. #+END_SRC
  1818. ** Install Owncloud
  1819. 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.
  1820. #+BEGIN_SRC: bash
  1821. emacs /etc/php5/apache2filter/php.ini
  1822. #+END_SRC
  1823. Set the following:
  1824. #+BEGIN_SRC: bash
  1825. post_max_size = 32M
  1826. upload_max_filesize = 32M
  1827. #+END_SRC
  1828. Restart apache.
  1829. #+BEGIN_SRC: bash
  1830. service apache2 restart
  1831. #+END_SRC
  1832. Install some dependencies:
  1833. #+BEGIN_SRC: bash
  1834. apt-get install apache2 php5 php5-gd php-xml-parser php5-intl
  1835. apt-get install php5-sqlite php5-mysql smbclient curl libcurl3 php5-curl
  1836. #+END_SRC
  1837. Download owncloud.
  1838. #+BEGIN_SRC: bash
  1839. cd /tmp
  1840. wget http://freedombone.uk.to/owncloud.tar.bz2
  1841. #+END_SRC
  1842. Verify the download:
  1843. #+BEGIN_SRC: bash
  1844. md5 owncloud.tar.bz2
  1845. f43eabb746b5e339ee70d0a6aaf4a49c
  1846. #+END_SRC
  1847. Extract the archive. This may take a couple of minutes, so don't be alarmed that the system has crashed.
  1848. #+BEGIN_SRC: bash
  1849. export HOSTNAME=myownclouddomainname.com
  1850. tar -xjf owncloud.tar.bz2
  1851. #+END_SRC
  1852. Move the extracted files to your site.
  1853. #+BEGIN_SRC: bash
  1854. cp -r owncloud /var/www/$HOSTNAME
  1855. rm -rf /var/www/$HOSTNAME/htdocs
  1856. mv /var/www/$HOSTNAME/owncloud /var/www/$HOSTNAME/htdocs
  1857. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/
  1858. chmod 775 /var/www/$HOSTNAME/htdocs
  1859. chmod 664 /var/www/$HOSTNAME/htdocs/*
  1860. chmod g+s /var/www/$HOSTNAME/htdocs
  1861. #+END_SRC
  1862. With a web browser visit your domain and enter an administrator username and password.
  1863. ** Install Bitmessage
  1864. [[https://bitmessage.org][Bitmessage]] is a new type of messaging system intended to fulfill the same role as email, but without the security problems. In particular, Bitmessage attempts to not just encrypt the content but also the metadata. It's message broadcasting system makes it exceedingly difficult for an attacker to know which computer a message is destined for. The only way you know whether a message has been sent to you is whether you are able to decrypt it from the passing stream of messages.
  1865. Although similar to Bitcoin in some regards, such as "/proof of work/", Bitmessage has no block chain and messages are only buffered for approximately three days after which they are deleted from any given node.
  1866. Installing Bitmessage as a daemon will increase the size of the network, and therefore the level of security for all users.
  1867. #+BEGIN_SRC: bash
  1868. apt-get install python screen
  1869. cd /tmp
  1870. git clone https://github.com/Bitmessage/PyBitmessage.git
  1871. cd PyBitmessage
  1872. make install
  1873. #+END_SRC
  1874. Save and exit.
  1875. #+BEGIN_SRC: bash
  1876. emacs /etc/init.d/pybitmessage
  1877. #+END_SRC
  1878. Add the following text:
  1879. #+BEGIN_SRC: bash
  1880. #!/bin/bash
  1881. # /etc/init.d/bitmessage
  1882. ### BEGIN INIT INFO
  1883. # Provides: pybitmessage
  1884. # Required-Start: $remote_fs $syslog
  1885. # Required-Stop: $remote_fs $syslog
  1886. # Default-Start: 2 3 4 5
  1887. # Default-Stop: 0 1 6
  1888. # Short-Description: starts bitmessage as a background daemon, suitable for servers
  1889. # Description: This file should be used to construct scripts to be
  1890. # placed in /etc/init.d.
  1891. ### END INIT INFO
  1892. # Author: Super-Nathan <BM-Gu2k3Wy2hpTMYBxSoM2937SPcuU6xzEj>
  1893. #Settings
  1894. SERVICE='pybitmessage'
  1895. LOGFILE='/dev/null' # this disables logging
  1896. # LOGFILE='/var/log/bitmessage.log' # comment out the above line and un-comment this line to save a log
  1897. COMMAND="python bitmessagemain.py > $LOGFILE"
  1898. USERNAME='bitmsg'
  1899. NICELEVEL=19 # from 0-19 the bigger the number, the less the impact on system resources
  1900. HISTORY=1024
  1901. PBM_LOCATION="/usr/local/share/pybitmessage"
  1902. INVOCATION="nice -n ${NICELEVEL} ${COMMAND}"
  1903. PATH='/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl:/sbin:/usr/sbin:/bin:/usr/local/share/pybitmessage'
  1904. bm_start() {
  1905. echo "Starting $SERVICE..."
  1906. cd ${PBM_LOCATION}
  1907. su --command "screen -h ${HISTORY} -dmS ${SERVICE} ${INVOCATION}" $USERNAME
  1908. }
  1909. bm_stop() {
  1910. echo "Stopping $SERVICE"
  1911. su --command "screen -p 0 -S ${SERVICE} -X stuff "'^C'"" $USERNAME
  1912. }
  1913. #Start-Stop here
  1914. case "$1" in
  1915. start)
  1916. bm_start
  1917. ;;
  1918. stop)
  1919. bm_stop
  1920. ;;
  1921. restart)
  1922. bm_stop
  1923. sleep 60s
  1924. bm_start
  1925. ;;
  1926. *)
  1927. echo "Usage: $0 {start|stop|restart}"
  1928. exit 1
  1929. ;;
  1930. esac
  1931. exit 0
  1932. #+END_SRC
  1933. Save and exit.
  1934. Add a user which will be specifically for Bitmessage. Since bitmessage is still a relatively young and experimental project, this adds further compartmentalisation such that if there are any bugs within PyBitmessage then an attacker can't neccessarily gain control of root or any other user account. Here we create a user called /bitmsg/ and give it a long random password.
  1935. #+BEGIN_SRC: bash
  1936. adduser bitmsg
  1937. #+END_SRC
  1938. Create a /keys.dat/ file which is used to configure Bitmessage.
  1939. #+BEGIN_SRC: bash
  1940. mkdir /home/bitmsg/.config
  1941. mkdir /home/bitmsg/.config/PyBitmessage
  1942. emacs /home/bitmsg/.config/PyBitmessage/keys.dat
  1943. #+END_SRC
  1944. Add the following:
  1945. #+BEGIN_SRC: bash
  1946. [bitmessagesettings]
  1947. settingsversion = 7
  1948. port = 8444
  1949. timeformat = %%a, %%d %%b %%Y %%I:%%M %%p
  1950. blackwhitelist = black
  1951. startonlogon = false
  1952. minimizetotray = false
  1953. showtraynotifications = false
  1954. startintray = false
  1955. socksproxytype = none
  1956. sockshostname = localhost
  1957. socksport = 9050
  1958. socksauthentication = false
  1959. sockslisten = false
  1960. socksusername =
  1961. sockspassword =
  1962. keysencrypted = false
  1963. messagesencrypted = false
  1964. defaultnoncetrialsperbyte = 640
  1965. defaultpayloadlengthextrabytes = 14000
  1966. minimizeonclose = false
  1967. maxacceptablenoncetrialsperbyte = 0
  1968. maxacceptablepayloadlengthextrabytes = 0
  1969. userlocale = system
  1970. namecoinrpctype = namecoind
  1971. namecoinrpchost = localhost
  1972. namecoinrpcuser =
  1973. namecoinrpcpassword =
  1974. namecoinrpcport = 8336
  1975. sendoutgoingconnections = True
  1976. daemon = true
  1977. #+END_SRC
  1978. Save and exit. Then enable the daemon and run it.
  1979. #+BEGIN_SRC: bash
  1980. rm -f /tmp/-usr-local-share-pybitmessage-*.lock
  1981. chown -R bitmsg:bitmsg /home/bitmsg
  1982. chmod +x /etc/init.d/pybitmessage
  1983. update-rc.d pybitmessage defaults
  1984. service pybitmessage start
  1985. #+END_SRC
  1986. Now open port 8444 on your internet router or firewall and direct it to the BBB.
  1987. ** Install Tripwire
  1988. 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.
  1989. #+BEGIN_SRC: bash
  1990. apt-get install tripwire
  1991. export HOSTNAME=mydomainname.com
  1992. cd /etc/tripwire
  1993. cp arm-local.key $HOSTNAME-local.key
  1994. cp site.key $HOSTNAME-site.key
  1995. tripwire --init
  1996. tripwire --update-policy --secure-mode low /etc/tripwire/twpol.txt
  1997. tripwire --check --interactive
  1998. #+END_SRC
  1999. you will be asked for two passphrases ("site" and "local"). Make a note of these.
  2000. If you subsequently install any more packages or make configuration changes then update the policy again with:
  2001. #+BEGIN_SRC: bash
  2002. tripwire --update-policy --secure-mode low /etc/tripwire/twpol.txt
  2003. #+END_SRC
  2004. Also, to look for any rootkits.
  2005. #+BEGIN_SRC: bash
  2006. apt-get install rkhunter
  2007. #+END_SRC
  2008. * Router/Firewall ports
  2009. The following ports on your internet router/firewall should be forwarded to the BBB.
  2010. | Protocol | Port/s |
  2011. |------------+------------|
  2012. | Gopher | 70 |
  2013. | HTTP | 80 |
  2014. | HTTPS | 443 |
  2015. | IMAP | 143 |
  2016. | IRC SSL | 6670 |
  2017. | SIP | 5060..5061 |
  2018. | SMTP | 25 |
  2019. | SMTPS | 465 |
  2020. | SSH | 22 |
  2021. | XMPP | 5222..5223 |
  2022. | Bitmessage | 8444 |
  2023. * Hints and Tips
  2024. ** Messaging security
  2025. 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.
  2026. ** Restrictive/hostile user environments
  2027. 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:
  2028. http://www.coralbits.com/oterm/
  2029. https://github.com/davidmoreno/onion
  2030. ** Moving Domains
  2031. 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:
  2032. #+BEGIN_SRC: bash
  2033. find /var/www/mynewdomain/htdocs -type f -exec sed -i 's@myolddomain@mynewdomain@g' {} \;
  2034. #+END_SRC
  2035. ** MySql foo
  2036. *** Backup all databases
  2037. To back up all mysql databases:
  2038. #+BEGIN_SRC: bash
  2039. mysqldump -u root -p --all-databases --events > /var/backups/databasebackup.sql
  2040. #+END_SRC
  2041. *** Restoring a particular mysql database
  2042. To restore yesterday's friendica backup:
  2043. #+BEGIN_SRC: bash
  2044. mysql -D friendica -o < /var/backups/friendica_daily.sql
  2045. #+END_SRC
  2046. To restore yesterday's mediawiki backup:
  2047. #+BEGIN_SRC: bash
  2048. mysql -D wikidb -o < /var/backups/wikidb_daily.sql
  2049. #+END_SRC
  2050. *** Removing mysql server
  2051. If you manage to screw up sql server completely then it can be fully deleted with:
  2052. #+BEGIN_SRC: bash
  2053. ps aux | grep mysql
  2054. #+END_SRC
  2055. and use /kill -9 <pid>/ to kill all mysql processes.
  2056. #+BEGIN_SRC: bash
  2057. apt-get remove --purge mysql\*
  2058. apt-get clean
  2059. updatedb
  2060. #+END_SRC