beaglebone.txt 93KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976
  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, social network, irc, jabber, chat
  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. #+BEGIN_VERSE
  40. /You can’t help someone just by making a wish to do so, you have to take action./
  41. -- Dalai Lama
  42. #+END_VERSE
  43. These instructions assume that you have the following ingredients.
  44. ** A BeagleBone Black (BBB)
  45. 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.
  46. ** An internet connection
  47. 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.
  48. ** microSD card
  49. 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.
  50. 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.
  51. ** 5V/1A power supply
  52. 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.
  53. ** An ethernet patch cable
  54. Just an ordinary cat5 or cat6 cable that you can get from most electrical/computer stores.
  55. * Installing Debian onto the microSD card
  56. 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.
  57. Download the image.
  58. #+BEGIN_SRC: bash
  59. cd ~/
  60. wget http://freedombone.uk.to/debian-7.2-console-armhf-2013-11-15.tar.xz
  61. #+END_SRC
  62. Verify it.
  63. #+BEGIN_SRC: bash
  64. md5sum debian-7.2-console-armhf-2013-11-15.tar.xz
  65. 0a448f55d14f64c5a7eb3d7cb2c54185 debian-7.2-console-armhf-2013-11-15.tar.xz
  66. #+END_SRC
  67. Uncompress it.
  68. #+BEGIN_SRC: bash
  69. tar xJf debian-7.2-console-armhf-2013-11-15.tar.xz
  70. cd debian-7.2-console-armhf-2013-11-15
  71. #+END_SRC
  72. Create the disk image, where sdX is the name of the flash drive (probably it will be sdb or sdc).
  73. #+BEGIN_SRC: bash
  74. sudo apt-get install u-boot-tools
  75. sudo ./setup_sdcard.sh --mmc /dev/sdX --uboot bone --swap-file 1024
  76. #+END_SRC
  77. Once completed then safely remove the microSD card via your file manager (usually right click and "safely remove" or "eject").
  78. * Setup
  79. #+BEGIN_VERSE
  80. /Build the tools for a future you would want to live in/
  81. -- Kurt Opsahl
  82. #+END_VERSE
  83. ** Things to be aware of
  84. *** A note on ssh
  85. 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:
  86. #+BEGIN_SRC: bash
  87. ssh-keygen -R <IP address>
  88. #+END_SRC
  89. *** Passwords
  90. 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.
  91. ** Initial
  92. Plug the microSD card into the BBB and Connect the USB cable to your laptop/desktop, then login via ssh.
  93. #+BEGIN_SRC: bash
  94. ssh debian@192.168.7.2
  95. #+END_SRC
  96. The default password is /temppwd/
  97. Then log in as root:
  98. #+BEGIN_SRC: bash
  99. su
  100. #+END_SRC
  101. The default password is /root/
  102. The first thing to do is to change the passwords from their defaults.
  103. #+BEGIN_SRC: bash
  104. passwd
  105. #+END_SRC
  106. 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.
  107. #+BEGIN_SRC: bash
  108. nano /etc/network/interfaces
  109. #+END_SRC
  110. The resulting interfaces file should look like this:
  111. #+BEGIN_SRC: bash
  112. # This file describes the network interfaces available on your system
  113. # and how to activate them. For more information, see interfaces(5).
  114. # The loopback network interface
  115. auto lo
  116. iface lo inet loopback
  117. # The primary network interface
  118. allow-hotplug eth0
  119. iface eth0 inet static
  120. address 192.168.1.60
  121. netmask 255.255.255.0
  122. gateway 192.168.1.254
  123. dns-nameservers 213.73.91.35 85.214.20.141
  124. # Example to keep MAC address between reboots
  125. #hwaddress ether DA:AD:CE:EF:CA:FE
  126. # WiFi Example
  127. #auto wlan0
  128. #iface wlan0 inet dhcp
  129. # wpa-ssid "essid"
  130. # wpa-psk "password"
  131. # Ethernet/RNDIS gadget (g_ether)
  132. # ... or on host side, usbnet and random hwaddr
  133. # Note on some boards, usb0 is automaticly setup with an init script
  134. # in that case, to completely disable remove file [run_boot-scripts] from the boot partition
  135. #iface usb0 inet static
  136. # address 192.168.7.2
  137. # netmask 255.255.255.0
  138. # network 192.168.7.0
  139. # gateway 192.168.7.1
  140. #+END_SRC
  141. CTRL-O followed by ENTER to save, then CTRL-X to exit.
  142. 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.
  143. "gateway 192.168.1.254" should be the IP address of the router.
  144. Note that setting the DNS servers with dns-nameservers is important because some home routers do not allow you to change the DNS settings.
  145. Edit resolv.conf.
  146. #+BEGIN_SRC: bash
  147. nano /etc/resolv.conf
  148. #+END_SRC
  149. It should look something like the following:
  150. #+BEGIN_SRC: bash
  151. domain localdomain
  152. search localdomain
  153. nameserver 213.73.91.35
  154. nameserver 85.214.20.141
  155. #+END_SRC
  156. CTRL-O followed by ENTER to save, then CTRL-X to exit.
  157. 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.
  158. 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".
  159. ** Add a user
  160. Ssh back in to the BBB and login as root. In this example the BBB's IP address is 192.168.1.60.
  161. #+BEGIN_SRC: bash
  162. ssh-keygen -f "/home/myusername/.ssh/known_hosts" -R 192.168.1.60
  163. ssh debian@192.168.1.60
  164. su
  165. #+END_SRC
  166. 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.
  167. #+BEGIN_SRC: bash
  168. adduser myusername
  169. #+END_SRC
  170. 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.
  171. Remove the default debian user.
  172. #+BEGIN_SRC: bash
  173. userdel -r debian
  174. #+END_SRC
  175. ** Text editor
  176. For an editor which is less erratic than vi when used within a remote console such as Terminator.
  177. #+BEGIN_SRC: bash
  178. apt-get update
  179. apt-get install emacs
  180. #+END_SRC
  181. ** Random number generation
  182. #+BEGIN_VERSE
  183. /Near as I can tell, the answer on what has been requested is everything: deliberate weakenings of encryption algorithms, deliberate weakenings of random number generations, copies of master keys, encryption of the session key with an NSA-specific key … everything./
  184. -- Bruce Schneier, on the 2013 leaked NSA documents
  185. #+END_VERSE
  186. The security of encryption depends upon how random the pseudo-random number generation on your system is. If it isn't very random then it may be far more vulnerable to cryptanalysis, and it's known that in the past some dubious agencies have encouraged the use of flawed random number generators to assist with their prurient activities. Randomness - typically referred to as /entropy/ - is often gathered from factors such as the timing of key presses or mouse movements, but since the BBB won't have such devices plugged into it this reduces the amount of entropy available.
  187. To improve entropy generation there are two options. One is to install a kernel module which enables the hardware crypto available on the BBB, but that's a bit complicated and might have some stability implications. The other option is to install [[http://www.issihosts.com/haveged/][havegd]]. While not as good as a true hardware random number generator, havegd is better than the default pseudo-random number generation within the Linux kernel. To install it:
  188. #+BEGIN_SRC: bash
  189. apt-get install haveged
  190. #+END_SRC
  191. At the time of writing there is also some hardware called [[http://beagleboard.org/project/CryptoCape/][cryptocape]] being developed, with the intention of adding extra random number generation capabilities to the BBB.
  192. ** Alter ssh configuration
  193. Altering the ssh configuration will make it a little more secure than the standard Debian settings.
  194. #+BEGIN_SRC: bash
  195. emacs /etc/ssh/sshd_config
  196. #+END_SRC
  197. Check the following values:
  198. #+BEGIN_SRC: bash
  199. PermitRootLogin no
  200. X11Forwarding no
  201. ServerKeyBits 4096
  202. Protocol 2
  203. PermitEmptyPasswords no
  204. StrictModes yes
  205. #+END_SRC
  206. Append the following:
  207. #+BEGIN_SRC: bash
  208. Ciphers aes256-ctr,aes192-ctr,aes128-ctr
  209. MACs hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
  210. KexAlgorithms diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1
  211. #+END_SRC
  212. CTRL-X CTRL-S to save, then CTRL-X CTRL-C to exit.
  213. #+BEGIN_SRC: bash
  214. service ssh restart
  215. #+END_SRC
  216. To test the new settings log out by typing "exit" a couple of times, then log back in again with:
  217. #+BEGIN_SRC: bash
  218. ssh -vvv myusername@192.168.1.60
  219. #+END_SRC
  220. and check that some number of bits are set within a 4096 bit sized key:
  221. #+BEGIN_SRC: bash
  222. debug2: bits set: */4096
  223. #+END_SRC
  224. ** Set the host name
  225. #+BEGIN_SRC: bash
  226. emacs /etc/hostname
  227. #+END_SRC
  228. CTRL-X CTRL-S to save, then CTRL-X CTRL-C to exit.
  229. also issue the command
  230. #+BEGIN_SRC: bash
  231. hostname /myhostname/
  232. #+END_SRC
  233. You may also need to assign the same hostname separately via your router's web interface.
  234. ** Install NTP
  235. To synchronise time.
  236. #+BEGIN_SRC: bash
  237. apt-get install ntp
  238. #+END_SRC
  239. ** Install fail2ban
  240. #+BEGIN_SRC: bash
  241. apt-get install fail2ban
  242. #+END_SRC
  243. ** Getting onto the web
  244. 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.
  245. Select "/dynamic DNS/" then click "/quick cron example/"
  246. An example would look like:
  247. #+BEGIN_SRC: bash
  248. 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 &
  249. #+END_SRC
  250. Edit /etc/crontab and append that to the end of the file.
  251. 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.
  252. ** install Email
  253. #+BEGIN_VERSE
  254. /If you knew what I know about email, you might not use it/
  255. -- Ladar Levison
  256. #+END_VERSE
  257. 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.
  258. Exim4 seems much easier to install and configure than Postfix.
  259. #+BEGIN_SRC: bash
  260. aptitude install exim4 sasl2-bin swaks libnet-ssleay-perl
  261. #+END_SRC
  262. You will be prompted to remove postfix. Say yes and yes again.
  263. #+BEGIN_SRC: bash
  264. dpkg-reconfigure exim4-config
  265. #+END_SRC
  266. Settings as follows:
  267. #+BEGIN_SRC: bash
  268. internet site
  269. System mail name: mydomainname.com
  270. IP addresses to listen on: blank
  271. Destinations: mydomainname.com
  272. Domains to relay mail: blank
  273. Smarthost Relay: 192.168.1.0/60 (the range of addresses on your LAN)
  274. Dial on demand = no
  275. Maildir format in home directory
  276. Split configuration = no
  277. Root and postmaster: root email
  278. #+END_SRC
  279. To test the installation:
  280. #+BEGIN_SRC: bash
  281. telnet 192.168.1.60 25
  282. ehlo xxx
  283. quit
  284. #+END_SRC
  285. #+BEGIN_SRC: bash
  286. emacs /etc/default/saslauthd
  287. #+END_SRC
  288. set START=yes then save and exit.
  289. #+BEGIN_SRC: bash
  290. /etc/init.d/saslauthd start
  291. emacs exim-gencert
  292. #+END_SRC
  293. #+BEGIN_SRC: bash
  294. #!/bin/sh -e
  295. if [ -n "$EX4DEBUG" ]; then
  296. echo "now debugging $0 $@"
  297. set -x
  298. fi
  299. DIR=/etc/exim4
  300. CERT=$DIR/exim.crt
  301. KEY=$DIR/exim.key
  302. # This exim binary was built with GnuTLS which does not support dhparams
  303. # from a file. See /usr/share/doc/exim4-base/README.Debian.gz
  304. #DH=$DIR/exim.dhparam
  305. if ! which openssl > /dev/null ;then
  306. echo "$0: openssl is not installed, exiting" 1>&2
  307. exit 1
  308. fi
  309. # valid for ten years
  310. DAYS=3650
  311. if [ "$1" != "--force" ] && [ -f $CERT ] && [ -f $KEY ]; then
  312. echo "[*] $CERT and $KEY exists!"
  313. echo " Use \"$0 --force\" to force generation!"
  314. exit 0
  315. fi
  316. if [ "$1" = "--force" ]; then
  317. shift
  318. fi
  319. #SSLEAY=/tmp/exim.ssleay.$$.cnf
  320. SSLEAY="$(tempfile -m600 -pexi)"
  321. cat > $SSLEAY <<EOM
  322. RANDFILE = $HOME/.rnd
  323. [ req ]
  324. default_bits = 4096
  325. default_keyfile = exim.key
  326. distinguished_name = req_distinguished_name
  327. [ req_distinguished_name ]
  328. countryName = Country Code (2 letters)
  329. countryName_default = GB
  330. countryName_min = 2
  331. countryName_max = 2
  332. stateOrProvinceName = State or Province Name (full name)
  333. localityName = Locality Name (eg, city)
  334. organizationName = Organization Name (eg, company; recommended)
  335. organizationName_max = 64
  336. organizationalUnitName = Organizational Unit Name (eg, section)
  337. organizationalUnitName_max = 64
  338. commonName = Server name (eg. ssl.domain.tld; required!!!)
  339. commonName_max = 64
  340. emailAddress = Email Address
  341. emailAddress_max = 40
  342. EOM
  343. echo "[*] Creating a self signed SSL certificate for Exim!"
  344. echo " This may be sufficient to establish encrypted connections but for"
  345. echo " secure identification you need to buy a real certificate!"
  346. echo " "
  347. echo " Please enter the hostname of your MTA at the Common Name (CN) prompt!"
  348. echo " "
  349. openssl req -config $SSLEAY -x509 -sha256 -newkey rsa:4096 -keyout $KEY -out $CERT -days $DAYS -nodes
  350. #see README.Debian.gz*# openssl dhparam -check -text -5 512 -out $DH
  351. rm -f $SSLEAY
  352. chown root:Debian-exim $KEY $CERT $DH
  353. chmod 640 $KEY $CERT $DH
  354. echo "[*] Done generating self signed certificates for exim!"
  355. echo " Refer to the documentation and example configuration files"
  356. echo " over at /usr/share/doc/exim4-base/ for an idea on how to enable TLS"
  357. echo " support in your mail transfer agent."
  358. #+END_SRC
  359. Save and exit
  360. #+BEGIN_SRC: bash
  361. chmod +x exim-gencert
  362. ./exim-gencert
  363. #+END_SRC
  364. 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.
  365. #+BEGIN_SRC: bash
  366. emacs /etc/exim4/exim4.conf.template
  367. #+END_SRC
  368. Append the following:
  369. #+BEGIN_SRC: bash
  370. login_saslauthd_server:
  371. driver = plaintext
  372. public_name = LOGIN
  373. server_prompts = "Username:: : Password::"
  374. # don't send system passwords over unencrypted connections
  375. server_condition = ${if saslauthd{{$auth1}{$auth2}}{1}{0}}
  376. server_set_id = $auth1
  377. .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
  378. server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
  379. .endif
  380. #+END_SRC
  381. Search for the line *.ifdef MAIN_HARDCODE_PRIMARY_HOSTNAME* and above it insert the line:
  382. #+BEGIN_SRC: bash
  383. MAIN_HARDCODE_PRIMARY_HOSTNAME = mydomainname.com
  384. #+END_SRC
  385. Save and exit.
  386. #+BEGIN_SRC: bash
  387. emacs /etc/exim4/exim4.conf.template
  388. #+END_SRC
  389. Add the line:
  390. #+BEGIN_SRC: bash
  391. MAIN_TLS_ENABLE = true
  392. #+END_SRC
  393. Save and exit.
  394. #+BEGIN_SRC: bash
  395. emacs /etc/default/exim4
  396. change SMTPLISTENEROPTIONS to:
  397. SMTPLISTENEROPTIONS='-oX 465:25 -oP /var/run/exim4/exim.pid'
  398. #+END_SRC
  399. save and exit
  400. #+BEGIN_SRC: bash
  401. emacs /etc/exim4/exim4.conf.template
  402. under the section "main/03_exim4-config_tlsoptions"
  403. Add the following:
  404. tls_on_connect_ports=465
  405. #+END_SRC
  406. save and exit
  407. #+BEGIN_SRC: bash
  408. adduser myusername sasl
  409. addgroup Debian-exim sasl
  410. /etc/init.d/exim4 restart
  411. mkdir /etc/skel/Maildir
  412. #+END_SRC
  413. ** Spam filtering
  414. #+BEGIN_SRC: bash
  415. apt-get install spamassassin exim4-daemon-heavy
  416. emacs /etc/default/spamassassin
  417. #+END_SRC
  418. Set ENABLED=1 then save and exit.
  419. #+BEGIN_SRC: bash
  420. emacs /etc/exim4/exim4.conf.template
  421. #+END_SRC
  422. uncomment or change according to your configuration
  423. #+BEGIN_SRC: bash
  424. # For spam scanning, there is a similar option that defines the interface to
  425. # SpamAssassin. You do not need to set this if you are using the default, which
  426. # is shown in this commented example. As for virus scanning, you must also
  427. # modify the acl_check_data access control list to enable spam scanning.
  428. spamd_address = 127.0.0.1 783
  429. #+END_SRC
  430. add spam header in the /acl_check_data/ section:
  431. #+BEGIN_SRC: bash
  432. ### acl/40_exim4-config_check_data
  433. #################################
  434. # This ACL is used after the contents of a message have been received. This
  435. # is the ACL in which you can test a message's headers or body, and in
  436. # particular, this is where you can invoke external virus or spam scanners.
  437. acl_check_data:
  438. ...
  439. ...
  440. ...
  441. # See the exim docs and the exim wiki for more suitable examples.
  442. #
  443. # warn
  444. # spam = Debian-exim:true
  445. # add_header = X-Spam_score: $spam_score\n\
  446. # X-Spam_score_int: $spam_score_int\n\
  447. # X-Spam_bar: $spam_bar\n\
  448. # X-Spam_report: $spam_report
  449. # put headers in all messages (no matter if spam or not)
  450. warn spam = nobody:true
  451. add_header = X-Spam-Score: $spam_score ($spam_bar)
  452. add_header = X-Spam-Report: $spam_report
  453. # add second subject line with *SPAM* marker when message
  454. # is over threshold
  455. warn spam = nobody
  456. add_header = Subject: ***SPAM (score:$spam_score)*** $h_Subject:
  457. #+END_SRC
  458. Save and exit.
  459. Then restart
  460. #+BEGIN_SRC: bash
  461. exit
  462. emacs ~/.procmailrc
  463. #+END_SRC
  464. The text should look like the following.
  465. #+BEGIN_SRC: sh
  466. MAILDIR=$HOME/Maildir
  467. DEFAULT=$MAILDIR/
  468. LOGFILE=$HOME/log/procmail.log
  469. LOGABSTRACT=all
  470. # get spamassassin to check emails
  471. :0fw: .spamassassin.lock
  472. * < 256000
  473. | spamc
  474. # strong spam are discarded
  475. :0
  476. * ^X-Spam-Level: \*\*\*\*\*\*
  477. /dev/null
  478. # weak spam are kept just in case - clear this out every now and then
  479. :0
  480. * ^X-Spam-Level: \*\*\*\*\*
  481. .0-spam/
  482. # if it wasn't detected as spam, but is to a fake address, then we
  483. # know it is spam, so learn from that
  484. :0
  485. * !^(From|To|cc|bcc)[ :].*($USER|root|webmaster|admin|postmaster).*@acooke\.org
  486. * !^(From|To|cc|bcc)[ :].*@isti\.com
  487. # add mailing lists below
  488. * !^From[ :].*(snowmail_daily@...|Section@...|rforno@...|alert@...).*
  489. {
  490. # save in case of screw-ups, mailing lists, etc
  491. :0 c
  492. .0-spam/
  493. :0
  494. .learn-spam/
  495. }
  496. # otherwise, marginal spam goes here for revision
  497. :0
  498. * ^X-Spam-Level: \*\*
  499. .spam/
  500. #+END_SRC
  501. Save and exit.
  502. #+BEGIN_SRC: bash
  503. su
  504. emacs /usr/bin/filterspam
  505. #+END_SRC
  506. Add the following contents:
  507. #+BEGIN_SRC: bash
  508. #!/bin/bash
  509. USERNAME=$1
  510. MAILDIR=/home/$USERNAME/Maildir/.learn-spam
  511. if [ ! -d "$MAILDIR" ]; then
  512. exit
  513. fi
  514. for f in `ls $MAILDIR/cur`
  515. do
  516. spamc -L spam < "$MAILDIR/cur/$f" > /dev/null
  517. rm "$MAILDIR/cur/$f"
  518. done
  519. for f in `ls $MAILDIR/new`
  520. do
  521. spamc -L spam < "$MAILDIR/new/$f" > /dev/null
  522. rm "$MAILDIR/new/$f"
  523. done
  524. #+END_SRC
  525. Save and exit.
  526. #+BEGIN_SRC: bash
  527. emacs /usr/bin/filterham
  528. #+END_SRC
  529. Add the following contents:
  530. #+BEGIN_SRC: bash
  531. #!/bin/bash
  532. USERNAME=$1
  533. MAILDIR=/home/$USERNAME/Maildir/.learn-ham
  534. if [ ! -d "$MAILDIR" ]; then
  535. exit
  536. fi
  537. for f in `ls $MAILDIR/cur`
  538. do
  539. spamc -L ham < "$MAILDIR/cur/$f" > /dev/null
  540. rm "$MAILDIR/cur/$f"
  541. done
  542. for f in `ls $MAILDIR/new`
  543. do
  544. spamc -L ham < "$MAILDIR/new/$f" > /dev/null
  545. rm "$MAILDIR/new/$f"
  546. done
  547. #+END_SRC
  548. Save and exit.
  549. #+BEGIN_SRC: bash
  550. emacs /etc/crontab
  551. #+END_SRC
  552. Append the following, replacing *myusername* with your username.
  553. #+BEGIN_SRC: bash
  554. */3 * * * * root /usr/bin/filterspam myusername
  555. */3 * * * * root /usr/bin/filterham myusername
  556. #+END_SRC
  557. Save and exit.
  558. #+BEGIN_SRC: bash
  559. chmod 655 /usr/bin/filterspam /usr/bin/filterham
  560. service spamassassin restart
  561. service exim4 restart
  562. service cron restart
  563. #+END_SRC
  564. ** Install dovecot
  565. #+BEGIN_SRC: bash
  566. aptitude -y install dovecot-common dovecot-pop3d dovecot-imapd
  567. #+END_SRC
  568. #+BEGIN_SRC: bash
  569. emacs /etc/dovecot/dovecot.conf
  570. #+END_SRC
  571. # line 26: change ( if not listen IPv6 port )
  572. listen = *
  573. #+BEGIN_SRC: bash
  574. emacs /etc/dovecot/conf.d/10-auth.conf
  575. #+END_SRC
  576. # line 9: uncomment and change ( allow plain text auth )
  577. disable_plaintext_auth = no
  578. # line 99: add
  579. auth_mechanisms = plain login
  580. #+BEGIN_SRC: bash
  581. emacs /etc/dovecot/conf.d/10-mail.conf
  582. #+END_SRC
  583. # line 30: uncomment and add
  584. mail_location = maildir:~/Maildir
  585. #+BEGIN_SRC: bash
  586. service dovecot restart
  587. #+END_SRC
  588. ** Mutt email client
  589. #+BEGIN_VERSE
  590. /I dreamt last night that I was living in a surveillance state. I woke up and… I’m still in a surveillance state./
  591. -- Conrad Kramer
  592. #+END_VERSE
  593. #+BEGIN_SRC: bash
  594. apt-get install mutt lynx abook
  595. exit
  596. mkdir ~/.mutt
  597. echo "text/html; lynx -dump -width=78 -nolist %s | sed ‘s/^ //’; copiousoutput; needsterminal; nametemplate=%s.html" > ~/.mutt/mailcap
  598. #+END_SRC
  599. Save and exit.
  600. #+BEGIN_SRC: bash
  601. su
  602. emacs /etc/Muttrc
  603. #+END_SRC
  604. Append the following:
  605. #+BEGIN_SRC: bash
  606. set mbox_type=Maildir
  607. set folder="~/Maildir"
  608. set mask="!^\\.[^.]"
  609. set mbox="~/Maildir"
  610. set record="+.Sent"
  611. set postponed="+.Drafts"
  612. set spoolfile="~/Maildir"
  613. auto_view text/x-vcard text/html text/enriched
  614. set editor="emacsclient %s"
  615. macro index S "<tag-prefix><save-message>=.learn-spam<enter>" "move to learn-spam"
  616. macro pager S "<save-message>=.learn-spam<enter>" "move to learn-spam"
  617. macro index H "<tag-prefix><copy-message>=.learn-ham<enter>" "copy to learn-ham"
  618. macro pager H "<copy-message>=.learn-ham<enter>" "copy to learn-ham"
  619. #+END_SRC
  620. Save and exit.
  621. #+BEGIN_SRC: bash
  622. emacs /etc/mail/spamassassin/local.cf
  623. #+END_SRC
  624. Uncomment *use_bayes*, *bayes_auto_learn*
  625. Save and exit, then run:
  626. #+BEGIN_SRC: bash
  627. service spamassassin restart
  628. #+END_SRC
  629. Now to add an address book:
  630. #+BEGIN_SRC: bash
  631. emacs ~/.muttrc
  632. #+END_SRC
  633. Append the following:
  634. #+BEGIN_SRC: bash
  635. set alias_file=~/.mutt-alias
  636. source ~/.mutt-alias
  637. set query_command= "abook --mutt-query '%s'"
  638. macro index,pager A "<pipe-message>abook --add-email-quiet<return>" "add the sender address to abook"
  639. #+END_SRC
  640. Then save and exit.
  641. #+BEGIN_SRC: bash
  642. touch ~/.mutt-alias
  643. #+END_SRC
  644. 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.
  645. 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.
  646. Some useful keys to know are:
  647. | ESC / | Search for text within message contents |
  648. | "/" | Search for text within headers |
  649. | * | Move to the last message |
  650. | TAB | Move to the next unread message |
  651. | d | Delete a message |
  652. | u | Undelete a mail which is pending deletion |
  653. | $ | Delete all messages selected and check for new messages |
  654. | a | Add to the address book |
  655. | m | Send a new mail |
  656. | S | Mark a message as spam |
  657. | H | Mark a message as ham |
  658. ** K9 email client
  659. #+BEGIN_VERSE
  660. /The surveillance state is robust. It is robust politically, legally, and technically./
  661. -- Bruce Schneier
  662. #+END_VERSE
  663. *** Incoming server settings
  664. * Select settings/account settings
  665. * Select Fetching mail/incoming server
  666. * Enter your username and password
  667. * IMAP server should be your domain name
  668. * Security: SSL/TLS (always)
  669. * Authentication: Plain
  670. * Port: 993
  671. *** Outgoing (SMTP) server settings
  672. * Select settings/account settings
  673. * Select Sending mail/outgoing server
  674. * Set SMTP server to your domain name
  675. * Set Security to SSL/TLS (always)
  676. * Set port to 465
  677. ** Setting up a web site
  678. #+BEGIN_VERSE
  679. /I hope we will use the Net to cross barriers and connect cultures./
  680. -- Tim Berners-Lee
  681. #+END_VERSE
  682. Edit the apache configuration so that it doesn't run out of memory if there are a lot of connections.
  683. #+BEGIN_SRC: bash
  684. su
  685. emacs /etc/apache2/apache2.conf
  686. #+END_SRC
  687. Search for MaxClients and replace the value with 20 then save and exit.
  688. In the examples below replace mydomainname.com with your own domain.
  689. #+BEGIN_SRC: bash
  690. export HOSTNAME=mydomainname.com
  691. mkdir /var/www/$HOSTNAME
  692. mkdir /var/www/$HOSTNAME/htdocs
  693. emacs /etc/apache2/sites-available/$HOSTNAME
  694. #+END_SRC
  695. The Apache configuration for the site should look something like the following. Replace /mydonainname.com/ with the site domain name.
  696. #+BEGIN_SRC: bash
  697. <VirtualHost *:80>
  698. ServerAdmin myusername@mydomainname.com
  699. ServerName mydomainname.com
  700. DocumentRoot /var/www/mydomainname.com/htdocs
  701. <Directory />
  702. Options FollowSymLinks
  703. AllowOverride All
  704. </Directory>
  705. <Directory /var/www/mydomainname.com/htdocs/>
  706. Options All
  707. AllowOverride All
  708. Order allow,deny
  709. allow from all
  710. </Directory>
  711. # Don't serve .php~ or .php# files created by emacs
  712. <Files ~ "(^#.*#|~|\.sw[op])$">
  713. Order allow,deny
  714. Deny from all
  715. </Files>
  716. <IfModule headers_module>
  717. Header set X-Content-Type-Options nosniff
  718. Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate, private"
  719. Header set Pragma no-cache
  720. </IfModule>
  721. <Files .htaccess>
  722. deny from all
  723. </Files>
  724. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  725. <Directory "/usr/lib/cgi-bin">
  726. AllowOverride All
  727. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  728. Order allow,deny
  729. Allow from all
  730. </Directory>
  731. ErrorLog ${APACHE_LOG_DIR}/error.log
  732. # Possible values include: debug, info, notice, warn, error, crit,
  733. # alert, emerg.
  734. LogLevel warn
  735. CustomLog ${APACHE_LOG_DIR}/access.log combined
  736. </VirtualHost>
  737. <IfModule mod_ssl.c>
  738. <VirtualHost *:443>
  739. ServerAdmin myusername@mydomainname.com
  740. ServerName mydomainname.com
  741. DocumentRoot /var/www/mydomainname.com/htdocs
  742. <Directory />
  743. Options FollowSymLinks
  744. AllowOverride All
  745. </Directory>
  746. <Directory /var/www/mydomainname.com/htdocs/>
  747. Options All
  748. AllowOverride All
  749. Order allow,deny
  750. allow from all
  751. </Directory>
  752. # Don't serve .php~ or .php# files created by emacs
  753. <Files ~ "(^#.*#|~|\.sw[op])$">
  754. Order allow,deny
  755. Deny from all
  756. </Files>
  757. <IfModule headers_module>
  758. Header set X-Content-Type-Options nosniff
  759. Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate, private"
  760. Header set Pragma no-cache
  761. </IfModule>
  762. <Files .htaccess>
  763. deny from all
  764. </Files>
  765. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  766. <Directory "/usr/lib/cgi-bin">
  767. AllowOverride All
  768. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  769. Order allow,deny
  770. Allow from all
  771. </Directory>
  772. ErrorLog ${APACHE_LOG_DIR}/error.log
  773. # Possible values include: debug, info, notice, warn, error, crit,
  774. # alert, emerg.
  775. LogLevel warn
  776. CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
  777. # SSL Engine Switch:
  778. # Enable/Disable SSL for this virtual host.
  779. SSLEngine on
  780. # A self-signed certificate
  781. SSLCertificateFile /etc/ssl/certs/mydomainname.com.crt
  782. SSLCertificateKeyFile /etc/ssl/private/mydomainname.com.key
  783. # Options based on bettercrypto.org
  784. SSLProtocol All -SSLv2 -SSLv3
  785. SSLHonorCipherOrder On
  786. SSLCompression off
  787. 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
  788. # Add six earth month HSTS header for all users ...
  789. Header add Strict-Transport-Security "max-age=15768000"
  790. # If you want to protect all subdomains , use the following header
  791. # ALL subdomains HAVE TO support https if you use this !
  792. # Strict-Transport-Security: max-age=15768000 ; includeSubDomains
  793. # SSL Engine Options:
  794. # Set various options for the SSL engine.
  795. # o FakeBasicAuth:
  796. # Translate the client X.509 into a Basic Authorisation. This means that
  797. # the standard Auth/DBMAuth methods can be used for access control. The
  798. # user name is the `one line' version of the client's X.509 certificate.
  799. # Note that no password is obtained from the user. Every entry in the user
  800. # file needs this password: `xxj31ZMTZzkVA'.
  801. # o ExportCertData:
  802. # This exports two additional environment variables: SSL_CLIENT_CERT and
  803. # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
  804. # server (always existing) and the client (only existing when client
  805. # authentication is used). This can be used to import the certificates
  806. # into CGI scripts.
  807. # o StdEnvVars:
  808. # This exports the standard SSL/TLS related `SSL_*' environment variables.
  809. # Per default this exportation is switched off for performance reasons,
  810. # because the extraction step is an expensive operation and is usually
  811. # useless for serving static content. So one usually enables the
  812. # exportation for CGI and SSI requests only.
  813. # o StrictRequire:
  814. # This denies access when "SSLRequireSSL" or "SSLRequire" applied even
  815. # under a "Satisfy any" situation, i.e. when it applies access is denied
  816. # and no other module can change it.
  817. # o OptRenegotiate:
  818. # This enables optimized SSL connection renegotiation handling when SSL
  819. # directives are used in per-directory context.
  820. #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
  821. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  822. SSLOptions +StdEnvVars
  823. </FilesMatch>
  824. <Directory /usr/lib/cgi-bin>
  825. SSLOptions +StdEnvVars
  826. </Directory>
  827. # SSL Protocol Adjustments:
  828. # The safe and default but still SSL/TLS standard compliant shutdown
  829. # approach is that mod_ssl sends the close notify alert but doesn't wait for
  830. # the close notify alert from client. When you need a different shutdown
  831. # approach you can use one of the following variables:
  832. # o ssl-unclean-shutdown:
  833. # This forces an unclean shutdown when the connection is closed, i.e. no
  834. # SSL close notify alert is send or allowed to received. This violates
  835. # the SSL/TLS standard but is needed for some brain-dead browsers. Use
  836. # this when you receive I/O errors because of the standard approach where
  837. # mod_ssl sends the close notify alert.
  838. # o ssl-accurate-shutdown:
  839. # This forces an accurate shutdown when the connection is closed, i.e. a
  840. # SSL close notify alert is send and mod_ssl waits for the close notify
  841. # alert of the client. This is 100% SSL/TLS standard compliant, but in
  842. # practice often causes hanging connections with brain-dead browsers. Use
  843. # this only for browsers where you know that their SSL implementation
  844. # works correctly.
  845. # Notice: Most problems of broken clients are also related to the HTTP
  846. # keep-alive facility, so you usually additionally want to disable
  847. # keep-alive for those clients, too. Use variable "nokeepalive" for this.
  848. # Similarly, one has to force some clients to use HTTP/1.0 to workaround
  849. # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
  850. # "force-response-1.0" for this.
  851. BrowserMatch "MSIE [2-6]" \
  852. nokeepalive ssl-unclean-shutdown \
  853. downgrade-1.0 force-response-1.0
  854. # MSIE 7 and newer should be able to use keepalive
  855. BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  856. </VirtualHost>
  857. </IfModule>
  858. #+END_SRC
  859. Then to enable the site:
  860. #+BEGIN_SRC: bash
  861. a2ensite
  862. a2dissite default
  863. a2dissite default-ssl
  864. a2enmod rewrite
  865. a2enmod headers
  866. #+END_SRC
  867. Ensure that "NameVirtualHost *:443" is added to /etc/apache2/ports.conf. It should look something like the following:
  868. #+BEGIN_SRC: bash
  869. NameVirtualHost *:80
  870. Listen 80
  871. <IfModule mod_ssl.c>
  872. NameVirtualHost *:443
  873. Listen 443
  874. </IfModule>
  875. <IfModule mod_gnutls.c>
  876. NameVirtualHost *:443
  877. Listen 443
  878. </IfModule>
  879. #+END_SRC
  880. Create a self-signed certificate. The passphrase isn't important and will be removed, so make it easy (such as "password").
  881. #+BEGIN_SRC: bash
  882. emacs makecert
  883. #+END_SRC
  884. Enter the following:
  885. #+BEGIN_SRC: bash
  886. #!/bin/bash
  887. HOSTNAME=$1
  888. openssl genrsa -des3 -out $HOSTNAME.key 1024
  889. openssl req -new -x509 -nodes -sha1 -days 3650 -key $HOSTNAME.key -out $HOSTNAME.crt
  890. openssl rsa -in $HOSTNAME.key -out $HOSTNAME.new.key
  891. cp $HOSTNAME.new.key $HOSTNAME.key
  892. rm $HOSTNAME.new.key
  893. cp $HOSTNAME.key /etc/ssl/private
  894. chmod 400 /etc/ssl/private/$HOSTNAME.key
  895. cp $HOSTNAME.crt /etc/ssl/certs
  896. shred -zu $HOSTNAME.key $HOSTNAME.crt
  897. a2enmod ssl
  898. service apache2 restart
  899. #+END_SRC
  900. Save and exit.
  901. #+BEGIN_SRC: bash
  902. chmod +x makecert
  903. ./makecert mydomainname.com
  904. #+END_SRC
  905. 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.
  906. 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.
  907. ** Social Networking
  908. #+BEGIN_VERSE
  909. /Facebook is not your friend, it is a surveillance engine./
  910. -- Richard Stallman, Free Software Foundation
  911. #+END_VERSE
  912. *** Friendica
  913. **** Installation
  914. See [[Setting up a web site]] for details of how to update the Apache configuration for your Friendica site. You should have a separate domain name specifically to run Friendica on. It can't be installed in a subdirectory on a domain used for something else.
  915. Edit your Apache configuration and disable the port 80 (HTTP) version of the site. We only want to log into Friendica via HTTPS, so to prevent anyone from accidentally logging in insecurely:
  916. #+BEGIN_SRC: bash
  917. emacs /etc/apache2/sites-available/mydomainname.com
  918. #+END_SRC
  919. Within the section which begins with *<VirtualHost *:80>* change the following:
  920. #+BEGIN_SRC: bash
  921. <Directory /var/www/mydomainname.com/htdocs/>
  922. deny from all
  923. </Directory>
  924. #+END_SRC
  925. Save and exit, then restart the apache server.
  926. #+BEGIN_SRC: bash
  927. service apache2 restart
  928. #+END_SRC
  929. Now install some dependencies.
  930. #+BEGIN_SRC: bash
  931. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  932. #+END_SRC
  933. Enter an admin password for MySQL.
  934. Create a mysql database.
  935. #+BEGIN_SRC: bash
  936. mysql -u root -p
  937. create database friendica;
  938. CREATE USER 'friendicaadmin'@'localhost' IDENTIFIED BY 'password';
  939. GRANT ALL PRIVILEGES ON friendica.* TO 'friendicaadmin'@'localhost';
  940. quit
  941. #+END_SRC
  942. You may need to fix Git SSL problems.
  943. #+BEGIN_SRC: bash
  944. git config --global http.sslVerify true
  945. apt-get install ca-certificates
  946. cd ~/
  947. emacs .gitconfig
  948. #+END_SRC
  949. The .gitconfig file should look something like this:
  950. #+BEGIN_SRC: bash
  951. [http]
  952. sslVerify = true
  953. sslCAinfo = /etc/ssl/certs/ca-certificates.crt
  954. [user]
  955. email = myusername@mydomainname.com
  956. name = yourname
  957. #+END_SRC
  958. Get the source code.
  959. #+BEGIN_SRC: bash
  960. export HOSTNAME=mydomainname.com
  961. cd /var/www/$HOSTNAME
  962. mv htdocs htdocs_old
  963. git clone https://github.com/friendica/friendica.git htdocs
  964. chmod -R 755 htdocs
  965. chown -R www-data:www-data htdocs
  966. chown -R www-data:www-data htdocs/view/smarty3
  967. git clone https://github.com/friendica/friendica-addons.git htdocs/addon
  968. #+END_SRC
  969. 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.
  970. Install the poller.
  971. #+BEGIN_SRC: bash
  972. emacs /etc/crontab
  973. #+END_SRC
  974. and append the following, changing mydomainname.com to whatever your domain is.
  975. #+BEGIN_SRC: bash
  976. */10 * * * * root cd /var/www/mydomainname.com/htdocs; /usr/bin/php include/poller.php
  977. #+END_SRC
  978. Save and exit, then restart cron.
  979. #+BEGIN_SRC: bash
  980. service cron restart
  981. #+END_SRC
  982. You can improve the speed of Friendica database searches by adding the following indexes:
  983. #+BEGIN_SRC: bash
  984. mysql -u root -p
  985. use friendica;
  986. CREATE INDEX `uri_received` ON item(`uri`, `received`);
  987. CREATE INDEX `received_uri` ON item(`received`, `uri`);
  988. CREATE INDEX `contact-id_created` ON item(`contact-id`, created);
  989. CREATE INDEX `uid_network_received` ON item(`uid`, `network`, `received`);
  990. CREATE INDEX `uid_parent` ON item(`uid`, `parent`);
  991. CREATE INDEX `uid_received` ON item(`uid`, `received`);
  992. CREATE INDEX `uid_network_commented` ON item(`uid`, `network`, `commented`);
  993. CREATE INDEX `uid_title` ON item(uid, `title`);
  994. CREATE INDEX `created_contact-id` ON item(`created`, `contact-id`);
  995. quit
  996. #+END_SRC
  997. **** Backups
  998. 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.
  999. #+BEGIN_SRC: bash
  1000. emacs /etc/cron.daily/friendicabackup
  1001. #+END_SRC
  1002. Enter the following
  1003. #+BEGIN_SRC: bash
  1004. #!/bin/sh
  1005. MYSQL_PASSWORD=<mysql root password>
  1006. umask 0077
  1007. # Backup the database
  1008. mysqldump --password=$MYSQL_PASSWORD friendica > /var/backups/friendica_daily.sql
  1009. # Make the backup readable only by root
  1010. chmod 600 /var/backups/friendica_daily.sql
  1011. #+END_SRC
  1012. Save and exit.
  1013. #+BEGIN_SRC: bash
  1014. chmod 600 /etc/cron.daily/friendicabackup
  1015. chmod +x /etc/cron.daily/friendicabackup
  1016. emacs /etc/cron.weekly/friendicabackup
  1017. #+END_SRC
  1018. Enter the following
  1019. #+BEGIN_SRC: bash
  1020. #!/bin/sh
  1021. MYSQL_PASSWORD=<mysql root password>
  1022. umask 0077
  1023. # Backup the database
  1024. mysqldump --password=$MYSQL_PASSWORD friendica > /var/backups/friendica_weekly.sql
  1025. # Make the backup readable only by root
  1026. chmod 600 /var/backups/friendica_weekly.sql
  1027. #+END_SRC
  1028. Save and exit.
  1029. #+BEGIN_SRC: bash
  1030. chmod 600 /etc/cron.weekly/friendicabackup
  1031. chmod +x /etc/cron.weekly/friendicabackup
  1032. #+END_SRC
  1033. **** Recommended configuration
  1034. ***** Admin
  1035. 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.
  1036. 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.
  1037. Under the *themes* section select a few themes, including mobile themes which are suitable for phones or tablets.
  1038. 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.
  1039. 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]].
  1040. ***** Settings
  1041. Each user has their own customisable settings, typically available either via an icon or by an entry on a drop down menu.
  1042. Under *additional features* enable "/richtext editor/", "/post preview/", "/group filter/", "/network filter/", "/edit sent posts/" and "/dislike posts/".
  1043. Under *display settings* select your desktop and mobile themes.
  1044. 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.
  1045. **** To access from an Android device
  1046. ***** App
  1047. 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.
  1048. 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.
  1049. More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
  1050. ***** Mobile Theme
  1051. 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.
  1052. *** Red Matrix
  1053. **** Introduction
  1054. 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.
  1055. **** Prerequisites
  1056. 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.
  1057. 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.
  1058. **** Installation
  1059. See [[Setting up a web site]] for details of how to update the Apache configuration for your Red Matrix site. You should have a separate domain name specifically to run Red Matrix on. It can't be installed in a subdirectory on a domain used for something else.
  1060. Edit your Apache configuration and disable the port 80 (HTTP) version of the site. We only want to log into Red Matrix via HTTPS, so to prevent anyone from accidentally logging in insecurely:
  1061. #+BEGIN_SRC: bash
  1062. emacs /etc/apache2/sites-available/mydomainname.com
  1063. #+END_SRC
  1064. Within the section which begins with *<VirtualHost *:80>* change the following:
  1065. #+BEGIN_SRC: bash
  1066. <Directory /var/www/mydomainname.com/htdocs/>
  1067. deny from all
  1068. </Directory>
  1069. #+END_SRC
  1070. Save and exit, then restart the apache server.
  1071. #+BEGIN_SRC: bash
  1072. service apache2 restart
  1073. #+END_SRC
  1074. Now install some dependencies.
  1075. #+BEGIN_SRC: bash
  1076. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  1077. #+END_SRC
  1078. Enter an admin password for MySQL.
  1079. Create a mysql database.
  1080. #+BEGIN_SRC: bash
  1081. mysql -u root -p
  1082. create database redmatrix;
  1083. CREATE USER 'redmatrixadmin'@'localhost' IDENTIFIED BY 'password';
  1084. GRANT ALL PRIVILEGES ON redmatrix.* TO 'redmatrixadmin'@'localhost';
  1085. quit
  1086. #+END_SRC
  1087. You may need to fix Git SSL problems.
  1088. #+BEGIN_SRC: bash
  1089. git config --global http.sslVerify true
  1090. apt-get install ca-certificates
  1091. cd ~/
  1092. emacs .gitconfig
  1093. #+END_SRC
  1094. The .gitconfig file should look something like this:
  1095. #+BEGIN_SRC: bash
  1096. [http]
  1097. sslVerify = true
  1098. sslCAinfo = /etc/ssl/certs/ca-certificates.crt
  1099. [user]
  1100. email = myusername@mydomainname.com
  1101. name = yourname
  1102. #+END_SRC
  1103. Get the source code.
  1104. #+BEGIN_SRC: bash
  1105. export HOSTNAME=mydomainname.com
  1106. cd /var/www/$HOSTNAME
  1107. mv htdocs htdocs_old
  1108. git clone https://github.com/friendica/red.git htdocs
  1109. chmod -R 755 htdocs
  1110. chown -R www-data:www-data htdocs
  1111. mkdir htdocs/view/tpl/smarty3
  1112. chmod 777 htdocs/view/tpl
  1113. chmod 777 htdocs/view/tpl/smarty3
  1114. git clone https://github.com/friendica/red-addons.git htdocs/addon
  1115. #+END_SRC
  1116. 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.
  1117. Install the poller.
  1118. #+BEGIN_SRC
  1119. emacs /etc/crontab
  1120. #+END_SRC
  1121. and append the following, changing mydomainname.com to whatever your domain is.
  1122. #+BEGIN_SRC
  1123. */10 * * * * root cd /var/www/mydomainname.com/htdocs; /usr/bin/php include/poller.php
  1124. #+END_SRC
  1125. Save and exit, then restart cron.
  1126. #+BEGIN_SRC: bash
  1127. service cron restart
  1128. #+END_SRC
  1129. **** Backups
  1130. 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.
  1131. #+BEGIN_SRC: bash
  1132. emacs /etc/cron.daily/redmatrixbackup
  1133. #+END_SRC
  1134. Enter the following
  1135. #+BEGIN_SRC: bash
  1136. #!/bin/sh
  1137. MYSQL_PASSWORD=<mysql root password>
  1138. umask 0077
  1139. # Backup the database
  1140. mysqldump --password=$MYSQL_PASSWORD redmatrix > /var/backups/redmatrix_daily.sql
  1141. # Make the backup readable only by root
  1142. chmod 600 /var/backups/redmatrix_daily.sql
  1143. #+END_SRC
  1144. Save and exit.
  1145. #+BEGIN_SRC: bash
  1146. chmod 600 /etc/cron.daily/redmatrixbackup
  1147. chmod +x /etc/cron.daily/redmatrixbackup
  1148. emacs /etc/cron.weekly/redmatrixbackup
  1149. #+END_SRC
  1150. Enter the following
  1151. #+BEGIN_SRC: bash
  1152. #!/bin/sh
  1153. MYSQL_PASSWORD=<mysql root password>
  1154. umask 0077
  1155. # Backup the database
  1156. mysqldump --password=$MYSQL_PASSWORD redmatrix > /var/backups/redmatrix_weekly.sql
  1157. # Make the backup readable only by root
  1158. chmod 600 /var/backups/redmatrix_weekly.sql
  1159. #+END_SRC
  1160. Save and exit.
  1161. #+BEGIN_SRC: bash
  1162. chmod 600 /etc/cron.weekly/redmatrixbackup
  1163. chmod +x /etc/cron.weekly/redmatrixbackup
  1164. #+END_SRC
  1165. **** To access from an Android device
  1166. ***** App
  1167. 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.
  1168. 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.
  1169. More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
  1170. ** Install a Blog
  1171. #+BEGIN_VERSE
  1172. /When society gives censors wide and vague powers they never confine themselves to deserving targets. They are not snipers, but machine-gunners. Allow them to fire at will, and they will hit anything that moves./
  1173. -- Nick Cohen
  1174. #+END_VERSE
  1175. 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.
  1176. 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.
  1177. Download flatpress.
  1178. #+BEGIN_SRC: bash
  1179. cd /tmp
  1180. wget http://freedombone.uk.to/flatpress.tar.gz
  1181. #+END_SRC
  1182. Verify the download:
  1183. #+BEGIN_SRC: bash
  1184. md5sum flatpress.tar.gz
  1185. 6ad5c230a5cb1ac096ff657f1b138cc7 flatpress.tar.gz
  1186. #+END_SRC
  1187. Extract and install it.
  1188. #+BEGIN_SRC: bash
  1189. tar -xzvf flatpress.tar.gz
  1190. cd flatpress-*
  1191. cp -r * /var/www/$HOSTNAME/htdocs
  1192. rm -rf flatpress-*
  1193. rm -f flatpress.tar.gz
  1194. #+END_SRC
  1195. 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
  1196. ** Install a VoIP server
  1197. #+BEGIN_VERSE
  1198. /Our core principles, whether in software or sovereignty, have always been about freedom and dignity, for all people, on an equal basis/
  1199. -- David Sugar, GNU Telephony
  1200. #+END_VERSE
  1201. *** The server
  1202. 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.
  1203. Edit your package sources:
  1204. #+BEGIN_SRC: bash
  1205. emacs /etc/apt/sources.list
  1206. #+END_SRC
  1207. Append the following line:
  1208. #+BEGIN_SRC: bash
  1209. deb http://dev.gnutelephony.org/archive/ wheezy/
  1210. #+END_SRC
  1211. Save and exit.
  1212. 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
  1213. #+BEGIN_SRC: bash
  1214. apt-get install gnutelephony-keyring
  1215. #+END_SRC
  1216. After that it will be happy to accept it as a signed repository. The verification keys can also be directly fetched with
  1217. #+BEGIN_SRC: bash
  1218. cd /tmp
  1219. wget http://dev.gnutelephony.org/archive/wheezy/public.key
  1220. #+END_SRC
  1221. and manually added instead with
  1222. #+BEGIN_SRC: bash
  1223. apt-key add public.key
  1224. #+END_SRC
  1225. To make sure you have all dependencies, do
  1226. #+BEGIN_SRC: bash
  1227. apt-get update;apt-get dist-upgrade
  1228. #+END_SRC
  1229. Before we install anything, let's inspect what is available to us by using
  1230. #+BEGIN_SRC: bash
  1231. dpkg -l sipwitch
  1232. #+END_SRC
  1233. To see the main application. The columns will indicate if the package is installed, which version and a description of the package. Then do
  1234. #+BEGIN_SRC: bash
  1235. dpkg -l sipwitch-*
  1236. #+END_SRC
  1237. 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.
  1238. To install only the main application, do
  1239. #+BEGIN_SRC: bash
  1240. apt-get install sipwitch
  1241. #+END_SRC
  1242. and to install all supporting plugins:
  1243. #+BEGIN_SRC: bash
  1244. apt-get install sipwitch-plugin-scripting sipwitch-plugin-subscriber sipwitch-plugin-forward sipwitch-plugin-zeroconf
  1245. #+END_SRC
  1246. Add your user into the sipwitch group
  1247. #+BEGIN_SRC: bash
  1248. groupadd sipwitch
  1249. groupadd sipusers
  1250. usermod -aG sipwitch myusername
  1251. usermod -aG sipusers myusername
  1252. #+END_SRC
  1253. Then edit the configuration
  1254. #+BEGIN_SRC: bash
  1255. emacs /etc/sipwitch.conf
  1256. #+END_SRC
  1257. Change the *mapped* value from 200 to 20, since we don't want to be serving huge numbers of calls.
  1258. 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.
  1259. Do not set the *realm* value, as doing so seems to prevent the server from working.
  1260. Save and exit.
  1261. Create a digest string for your username:
  1262. #+BEGIN_SRC: bash
  1263. sipwitch digest myusername
  1264. #+END_SRC
  1265. Make a note of the resulting string because you're going to use it in the users file you'll now create.
  1266. #+BEGIN_SRC: bash
  1267. export HOSTNAME=mydomainname.com
  1268. touch /etc/sipwitch.d/$HOSTNAME.xml
  1269. chmod 600 /etc/sipwitch.d/$HOSTNAME.xml
  1270. emacs /etc/sipwitch.d/$HOSTNAME.xml
  1271. #+END_SRC
  1272. It should look something like the following:
  1273. #+BEGIN_SRC: bash
  1274. <provision>
  1275. <user id="myusername">
  1276. <digest>yourdigeststring</digest>
  1277. <extension>201</extension>
  1278. <display>Your full name</display>
  1279. </user>
  1280. </provision>
  1281. #+END_SRC
  1282. Save and exit. Now edit the configuration.
  1283. #+BEGIN_SRC: bash
  1284. emacs /etc/default/sipwitch
  1285. #+END_SRC
  1286. Change "desktop" to "server", then save and exit.
  1287. Update the IP settings:
  1288. #+BEGIN_SRC: bash
  1289. iptables -A INPUT -p tcp --dport 5060 -j ACCEPT
  1290. iptables -A INPUT -p udp --dport 5060 -j ACCEPT
  1291. iptables -A INPUT -p tcp --dport 5061 -j ACCEPT
  1292. iptables -A INPUT -p udp --dport 5061 -j ACCEPT
  1293. iptables-save
  1294. #+END_SRC
  1295. Test that it's working:
  1296. #+BEGIN_SRC: bash
  1297. pkill -9 sipw
  1298. sipw -x9 -f
  1299. #+END_SRC
  1300. 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.
  1301. #+BEGIN_SRC: bash
  1302. service sipwitch start
  1303. #+END_SRC
  1304. *** Clients
  1305. **** Jitsi
  1306. Download the latst version from https://jitsi.org/index.php/Main/Download
  1307. TODO
  1308. **** Twinkle client
  1309. The client should have a user profile as following:
  1310. The "user name" is the xxx id used in the <user id="xxx"> entry of /etc/sipwitch.conf
  1311. The "domain" is the yyy domain in the main config <stack><domain>yyy entry of /etc/sipwitch.conf
  1312. The SIP Authentication should have:
  1313. realm = realm as set in <registry><realm> of /etc/sipwitch.conf
  1314. authentication name = <user id="xx"> entry, same as "User Name" field.
  1315. password = value of <secret>zzz in <user> entry of /etc/sipwitch.conf
  1316. Under security tab, set "Enable ZRTP/SRTP encryption"
  1317. **** Android
  1318. TODO
  1319. CSipSimple?
  1320. ** Install an IRC server
  1321. #+BEGIN_VERSE
  1322. /Give me the liberty to know, to utter, and to argue freely according to conscience, above all liberties./
  1323. -- John Milton
  1324. #+END_VERSE
  1325. *** Base install
  1326. 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.
  1327. First install some dependencies.
  1328. #+BEGIN_SRC: bash
  1329. apt-get update
  1330. apt-get install build-essential openssl libssl-dev
  1331. #+END_SRC
  1332. Then get the source code for ircd-hybrid.
  1333. #+BEGIN_SRC: bash
  1334. cd /tmp
  1335. mkdir hybrid
  1336. cd hybrid
  1337. apt-get source ircd-hybrid
  1338. #+END_SRC
  1339. Modify the source code to include SSL security.
  1340. #+BEGIN_SRC: bash
  1341. emacs ircd-hybrid-*/debian/rules
  1342. #+END_SRC
  1343. Beneath MAXCLIENTS add the line:
  1344. #+BEGIN_SRC: bash
  1345. USE_OPENSSL = 1
  1346. #+END_SRC
  1347. Then save and exit. Now we can build the debian package for ircd-hybrid and install it.
  1348. #+BEGIN_SRC: bash
  1349. cd ircd-hybrid-*
  1350. dpkg-buildpackage -rfakeroot -uc -b
  1351. cd ..
  1352. dpkg -i ircd-hybrid_*.deb
  1353. #+END_SRC
  1354. 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.
  1355. #+BEGIN_SRC: bash
  1356. emacs /etc/ircd-hybrid/ircd.conf
  1357. #+END_SRC
  1358. Set *name* to the name of your server, and set a description.
  1359. Set a *network_name* and *network_desc*. The network name should not contain any spaces.
  1360. Set max_clients to 20, or however many you expect that you'll typically need.
  1361. Within the admin section set your *name* and *email*.
  1362. Within the *listen* section set host to your fixed IP address (in the earlier
  1363. sections it was 192.168.1.60).
  1364. Within the *auth* section set user = "*@192.168.1.60" - or whatever the fixed IP address of the BBB is on your network.
  1365. 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.
  1366. Save and exit, then restart the IRC server. Open port 6670 on your internet router and forward it to the BBB.
  1367. Ensure that the configuration is only readable by the root user.
  1368. #+BEGIN_SRC: bash
  1369. chmod 600 /etc/ircd-hybrid/ircd.conf
  1370. #+END_SRC
  1371. *** Channel management
  1372. To to install channel management tools.
  1373. #+BEGIN_SRC: bash
  1374. cd /tmp
  1375. wget http://freedombone.uk.to/hybserv_1.9.4-1_armhf.deb
  1376. #+END_SRC
  1377. Verify it.
  1378. #+BEGIN_SRC: bash
  1379. md5sum hybserv_1.9.4-1_armhf.deb
  1380. 5b66551ceabb679bdeda1859d23ca6ac hybserv_1.9.4-1_armhf.deb
  1381. #+END_SRC
  1382. Install it.
  1383. #+BEGIN_SRC: bash
  1384. dpkg -i hybserv_1.9.4-1_armhf.deb
  1385. #+END_SRC
  1386. Edit the configuration.
  1387. Make a md5 version of the password for the IRC server operator.
  1388. #+BEGIN_SRC: bash
  1389. /usr/bin/mkpasswd <myoperatorpassword>
  1390. #+END_SRC
  1391. Edit the ircd-hybrid configuration.
  1392. #+BEGIN_SRC: bash
  1393. emacs /etc/ircd-hybrid/ircd.conf
  1394. #+END_SRC
  1395. Enter the md5 password which you previously created within the /operator/ section. Also change /user/ to:
  1396. #+BEGIN_SRC: bash
  1397. user = "*@*";
  1398. #+END_SRC
  1399. Then save and exit.
  1400. #+BEGIN_SRC: bash
  1401. emacs /etc/hybserv/hybserv.conf
  1402. #+END_SRC
  1403. 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/.
  1404. #+BEGIN_SRC: bash
  1405. A:mynickname <myemailaddress>
  1406. N:irc.mydomainname.com:Hybrid services
  1407. O:*@*:#MD5 PASSWORD HERE#:root:segj (comment out other Q: lines)
  1408. S:mysendacceptpassword:192.168.1.60:6670 (remove the other two services)
  1409. #+END_SRC
  1410. Also remove the line *#NOT-EDITED#*, then save and exit.
  1411. Now we need to restart the ircd and hybrid server to make things work:
  1412. #+BEGIN_SRC: bash
  1413. service ircd-hybrid restart
  1414. service hybserv start
  1415. #+END_SRC
  1416. *** Usage
  1417. On another computer (not the BBB).
  1418. #+BEGIN_SRC: bash
  1419. sudo apt-get install irssi
  1420. irssi
  1421. #+END_SRC
  1422. Connect to the IRC and identify yourself as an operator. Here /mynetwork/ should be the same as *network_name* specified earlier within /ircd.conf/.
  1423. #+BEGIN_SRC: bash
  1424. /server add -auto -network mynetwork -ssl mydonainname.com 6670 mysendacceptpassword
  1425. /connect mydomainname.com
  1426. /channel add -auto #mychannel mynetwork channelpassword
  1427. /network add -nick mynick mychannel
  1428. /join #mychannel
  1429. /msg -servername chanserv REGISTER #mychannel channelpassword
  1430. /msg -servername chanserv set #mychannel mlock +k channelpassword
  1431. #+END_SRC
  1432. If you edit the irssi config file:
  1433. #+BEGIN_SRC: bash
  1434. emacs ~/.irssi/config
  1435. #+END_SRC
  1436. It should look something like this:
  1437. #+BEGIN_SRC: bash
  1438. {
  1439. address = "mydomainname.com";
  1440. chatnet = "mynetwork";
  1441. port = "6670";
  1442. password = "mysendacceptpassword";
  1443. use_ssl = "yes";
  1444. ssl_verify = "no";
  1445. autoconnect = "yes";
  1446. },
  1447. #+END_SRC
  1448. If you're not using a self-signed certificate (self-signed is the default) then you can set *ssl_verify* to "yes".
  1449. ** Install a Jabber/XMPP server
  1450. #+BEGIN_VERSE
  1451. /Well heck, it isn’t that hard to write an instant messaging system./
  1452. --Jeremie Miller
  1453. #+END_VERSE
  1454. *** The Server
  1455. Generate a SSL certificate.
  1456. #+BEGIN_SRC: bash
  1457. openssl ecparam -out /etc/ssl/private/xmpp.pem -name prime256v1
  1458. openssl genpkey -paramfile /etc/ssl/private/xmpp.pem -out /etc/ssl/private/xmpp.key
  1459. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  1460. #+END_SRC
  1461. 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:
  1462. #+BEGIN_SRC: bash
  1463. openssl genrsa -out /etc/ssl/private/xmpp.key 4096
  1464. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  1465. #+END_SRC
  1466. Change permissions.
  1467. #+BEGIN_SRC: bash
  1468. chmod 600 /etc/ssl/private/xmpp.key
  1469. chmod 600 /etc/ssl/certs/xmpp.crt
  1470. chown prosody:prosody /etc/ssl/private/xmpp.key
  1471. chown prosody:prosody /etc/ssl/certs/xmpp.crt
  1472. #+END_SRC
  1473. Install Prosody.
  1474. #+BEGIN_SRC: bash
  1475. apt-get install prosody
  1476. cp -a /etc/prosody/conf.avail/example.com.cfg.lua /etc/prosody/conf.avail/xmpp.cfg.lua
  1477. emacs /etc/prosody/conf.avail/xmpp.cfg.lua
  1478. #+END_SRC
  1479. Change the *VirtualHost* name to your domain name and remove the line below it.
  1480. Set the ssl section to:
  1481. #+BEGIN_SRC: bash
  1482. ssl = {
  1483. key = "/etc/ssl/private/xmpp.key";
  1484. certificate = "/etc/ssl/certs/xmpp.crt";
  1485. }
  1486. #+END_SRC
  1487. Save and exit. Create a symbolic link.
  1488. #+BEGIN_SRC: bash
  1489. ln -sf /etc/prosody/conf.avail/xmpp.cfg.lua /etc/prosody/conf.d/xmpp.cfg.lua
  1490. #+END_SRC
  1491. Add a user. You will be prompted to specify a password. You can repeat the process for as many users as needed. This will also be your Jabber ID (JID).
  1492. #+BEGIN_SRC: bash
  1493. prosodyctl adduser myusername@mydomainname.com
  1494. #+END_SRC
  1495. Restart the server
  1496. #+BEGIN_SRC: bash
  1497. service prosody restart
  1498. #+END_SRC
  1499. On your internet router/firewall open ports 5222, 5223 and 5269 and forward them to the BBB.
  1500. 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.
  1501. *** Managing users
  1502. To add a user:
  1503. #+BEGIN_SRC: bash
  1504. prosodyctl adduser myusername@mydomainname.com
  1505. #+END_SRC
  1506. To change a user password:
  1507. #+BEGIN_SRC: bash
  1508. prosodyctl passwd myusername@mydomainname.com
  1509. #+END_SRC
  1510. To remove a user:
  1511. #+BEGIN_SRC: bash
  1512. prosodyctl deluser myusername@mydomainname.com
  1513. #+END_SRC
  1514. Report the status of the XMPP server:
  1515. #+BEGIN_SRC: bash
  1516. prosodyctl status
  1517. #+END_SRC
  1518. *** Using with Jitsi
  1519. Jitsi is the recommended communications client for desktop or laptop systems, since it includes the /off the record/ (OTR) feature which provides some additional security beyond the usual SSL certificates.
  1520. Jitsi can be downloaded from https://jitsi.org/
  1521. On your desktop/laptop open Jitsi and select *Options* from the *Tools* menu.
  1522. Click *Add* to add a new user, then enter the Jabber ID which you previously specified with /prosodyctl/ when setting up the XMPP server. Close and then you should notice that your status is "Online" (or if not then you should be able to set it to online).
  1523. From the *File* menu you can add contacts, then select the chat icon to begin a chat. Click on the lock icon on the right hand side and this will initiate an authentication procedure in which you can specify a question and answer to verify the identity of the person you're communicating with. Once authentication is complete then you'll be chating using OTR, which provides an additional layer of security.
  1524. You can also [[https://www.youtube.com/watch?v=vgx7VSrDGjk][see this video]] as an example of using OTR.
  1525. *** Using with Ubuntu
  1526. The default XMPP client in Ubuntu is Empathy. Using Empathy isn't as secure as using Jitsi, since it doesn't include the /off the record/ feature, but since it's the default it's what many users will have easy access to.
  1527. Open *System Settings* and select *Online Accounts*, *Add account* and then *Jabber*.
  1528. Enter your username (myusername@mydomainname.com) and password.
  1529. 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*.
  1530. *** Using with Android
  1531. Install [[https://f-droid.org/][F-Droid]]
  1532. Search for and install Gibberbot
  1533. From the menu open *Accounts*
  1534. Select *Add account*
  1535. Change the server port from 0 to 5222
  1536. Done
  1537. Accept unknown certificate? Select *Always*
  1538. Go back to the initial screen and then using the menu you can add contacts and begin chatting.
  1539. ** Install Gopher
  1540. 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.
  1541. To set up a gopher server:
  1542. #+BEGIN_SRC: bash
  1543. apt-get install build-essential
  1544. cd /tmp
  1545. wget http://freedombone.uk.to/geomyidae-current.tgz
  1546. #+END_SRC
  1547. Verify the download:
  1548. #+BEGIN_SRC: bash
  1549. md5sum geomyidae-current.tgz
  1550. 3d8bb8601f37ca953b00fc2445ab5abe geomyidae-current.tgz
  1551. #+END_SRC
  1552. Then extract and install it.
  1553. #+BEGIN_SRC: bash
  1554. tar -xzvf geomyidae-current.tgz
  1555. cd geomyidae-*
  1556. make
  1557. make install
  1558. mkdir -p /var/gopher
  1559. #+END_SRC
  1560. 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.
  1561. #+BEGIN_SRC: bash
  1562. emacs /etc/init.d/gopher
  1563. #+END_SRC
  1564. Enter the following:
  1565. #+BEGIN_SRC: bash
  1566. #! /bin/sh
  1567. ### BEGIN INIT INFO
  1568. # Provides: gopher
  1569. # Required-Start: $remote_fs $syslog
  1570. # Required-Stop: $remote_fs $syslog
  1571. # Default-Start: 2 3 4 5
  1572. # Default-Stop: 0 1 6
  1573. # Short-Description: Gopher daemon
  1574. # Description: Gopher daemon
  1575. ### END INIT INFO
  1576. # Do NOT "set -e"
  1577. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  1578. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  1579. DESC="Gopher daemon"
  1580. NAME=geomyidae
  1581. DAEMON=/usr/bin/$NAME
  1582. DAEMON_ARGS="-l /var/log/geomyidae.log -b /var/gopher -p 70"
  1583. PIDFILE=/var/run/$NAME.pid
  1584. SCRIPTNAME=/etc/init.d/$NAME
  1585. # Exit if the package is not installed
  1586. [ -x "$DAEMON" ] || exit 0
  1587. # Read configuration variable file if it is present
  1588. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  1589. # Load the VERBOSE setting and other rcS variables
  1590. . /lib/init/vars.sh
  1591. # Define LSB log_* functions.
  1592. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
  1593. # and status_of_proc is working.
  1594. . /lib/lsb/init-functions
  1595. #
  1596. # Function that starts the daemon/service
  1597. #
  1598. do_start()
  1599. {
  1600. # Return
  1601. # 0 if daemon has been started
  1602. # 1 if daemon was already running
  1603. # 2 if daemon could not be started
  1604. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
  1605. || return 1
  1606. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
  1607. $DAEMON_ARGS \
  1608. || return 2
  1609. # Add code here, if necessary, that waits for the process to be ready
  1610. # to handle requests from services started subsequently which depend
  1611. # on this one. As a last resort, sleep for some time.
  1612. }
  1613. #
  1614. # Function that stops the daemon/service
  1615. #
  1616. do_stop()
  1617. {
  1618. # Return
  1619. # 0 if daemon has been stopped
  1620. # 1 if daemon was already stopped
  1621. # 2 if daemon could not be stopped
  1622. # other if a failure occurred
  1623. start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
  1624. RETVAL="$?"
  1625. [ "$RETVAL" = 2 ] && return 2
  1626. # Wait for children to finish too if this is a daemon that forks
  1627. # and if the daemon is only ever run from this initscript.
  1628. # If the above conditions are not satisfied then add some other code
  1629. # that waits for the process to drop all resources that could be
  1630. # needed by services started subsequently. A last resort is to
  1631. # sleep for some time.
  1632. start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
  1633. [ "$?" = 2 ] && return 2
  1634. # Many daemons don't delete their pidfiles when they exit.
  1635. rm -f $PIDFILE
  1636. return "$RETVAL"
  1637. }
  1638. #
  1639. # Function that sends a SIGHUP to the daemon/service
  1640. #
  1641. do_reload() {
  1642. #
  1643. # If the daemon can reload its configuration without
  1644. # restarting (for example, when it is sent a SIGHUP),
  1645. # then implement that here.
  1646. #
  1647. start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
  1648. return 0
  1649. }
  1650. case "$1" in
  1651. start)
  1652. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  1653. do_start
  1654. case "$?" in
  1655. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  1656. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  1657. esac
  1658. ;;
  1659. stop)
  1660. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  1661. do_stop
  1662. case "$?" in
  1663. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  1664. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  1665. esac
  1666. ;;
  1667. status)
  1668. status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  1669. ;;
  1670. #reload|force-reload)
  1671. #
  1672. # If do_reload() is not implemented then leave this commented out
  1673. # and leave 'force-reload' as an alias for 'restart'.
  1674. #
  1675. #log_daemon_msg "Reloading $DESC" "$NAME"
  1676. #do_reload
  1677. #log_end_msg $?
  1678. #;;
  1679. restart|force-reload)
  1680. #
  1681. # If the "reload" option is implemented then remove the
  1682. # 'force-reload' alias
  1683. #
  1684. log_daemon_msg "Restarting $DESC" "$NAME"
  1685. do_stop
  1686. case "$?" in
  1687. 0|1)
  1688. do_start
  1689. case "$?" in
  1690. 0) log_end_msg 0 ;;
  1691. 1) log_end_msg 1 ;; # Old process is still running
  1692. *) log_end_msg 1 ;; # Failed to start
  1693. esac
  1694. ;;
  1695. *)
  1696. # Failed to stop
  1697. log_end_msg 1
  1698. ;;
  1699. esac
  1700. ;;
  1701. *)
  1702. #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  1703. echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
  1704. exit 3
  1705. ;;
  1706. esac
  1707. :
  1708. #+END_SRC
  1709. Save and exit. Then start the gopher service.
  1710. #+BEGIN_SRC: bash
  1711. chmod +x /etc/init.d/gopher
  1712. update-rc.d gopher defaults
  1713. service gopher start
  1714. #+END_SRC
  1715. 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:
  1716. #+BEGIN_SRC: bash
  1717. gopher://mydomainname.com
  1718. #+END_SRC
  1719. There is a browser addon for Gopher called "overbite". Installing that should enable you to view your site.
  1720. ** Install a Wiki
  1721. #+BEGIN_VERSE
  1722. /I believe that technology can liberate, but you need to be a master rather than a user. You need to pull technology apart and master it rather than letting it control you./
  1723. -- Tom Barbalet
  1724. #+END_VERSE
  1725. Dokuwiki is based upon flat files, and so is easy to move from one server to another without a lot of database complications.
  1726. Download the wiki.
  1727. #+BEGIN_SRC: bash
  1728. cd /tmp
  1729. wget http://freedombone.uk.to/dokuwiki.tgz
  1730. #+END_SRC
  1731. Verify it.
  1732. #+BEGIN_SRC: bash
  1733. md5sum dokuwiki.tgz
  1734. 9f35055848429659fd63cda1cfea5a48 dokuwiki.tgz
  1735. #+END_SRC
  1736. Then extract and install it.
  1737. #+BEGIN_SRC: bash
  1738. export HOSTNAME=mywikidomainname.com
  1739. tar -xzvf dokuwiki.tgz
  1740. mv /var/www/$HOSTNAME/htdocs /var/www/$HOSTNAME/htdocs_old
  1741. mv dokuwiki /var/www/$HOSTNAME/htdocs
  1742. #+END_SRC
  1743. Edit the Apache configuration for your wiki site.
  1744. #+BEGIN_SRC: bash
  1745. emacs /etc/apache2/sites-available/$HOSTNAME
  1746. #+END_SRC
  1747. The settings should look something like the following.
  1748. #+BEGIN_SRC: bash
  1749. <VirtualHost *:80>
  1750. ServerAdmin myusername@mywikidomainname.com
  1751. ServerName mydomainname.com
  1752. DocumentRoot /var/www/mywikidomainname.com/htdocs
  1753. <Directory /var/www/mywikidomainname.com/htdocs>
  1754. order deny,allow
  1755. allow from all
  1756. </Directory>
  1757. <LocationMatch "/(data|conf|bin|inc)/">
  1758. order allow,deny
  1759. deny from all
  1760. satisfy all
  1761. </LocationMatch>
  1762. <Directory />
  1763. Options FollowSymLinks
  1764. AllowOverride All
  1765. </Directory>
  1766. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  1767. <Directory "/usr/lib/cgi-bin">
  1768. AllowOverride All
  1769. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  1770. Order allow,deny
  1771. Allow from all
  1772. </Directory>
  1773. ErrorLog ${APACHE_LOG_DIR}/error.log
  1774. # Possible values include: debug, info, notice, warn, error, crit,
  1775. # alert, emerg.
  1776. LogLevel warn
  1777. CustomLog ${APACHE_LOG_DIR}/access.log combined
  1778. </VirtualHost>
  1779. <IfModule mod_ssl.c>
  1780. <VirtualHost *:443>
  1781. ServerAdmin myusername@mywikidomainname.com
  1782. ServerName mywikidomainname.com
  1783. DocumentRoot /var/www/mywikidomainname.com/htdocs
  1784. <Directory /var/www/mywikidomainname.com/htdocs>
  1785. order deny,allow
  1786. allow from all
  1787. </Directory>
  1788. <LocationMatch "/(data|conf|bin|inc)/">
  1789. order allow,deny
  1790. deny from all
  1791. satisfy all
  1792. </LocationMatch>
  1793. <Directory />
  1794. Options FollowSymLinks
  1795. AllowOverride All
  1796. </Directory>
  1797. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  1798. <Directory "/usr/lib/cgi-bin">
  1799. AllowOverride All
  1800. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  1801. Order allow,deny
  1802. Allow from all
  1803. </Directory>
  1804. ErrorLog ${APACHE_LOG_DIR}/error.log
  1805. # Possible values include: debug, info, notice, warn, error, crit,
  1806. # alert, emerg.
  1807. LogLevel warn
  1808. CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
  1809. # SSL Engine Switch:
  1810. # Enable/Disable SSL for this virtual host.
  1811. SSLEngine on
  1812. # A self-signed certificate
  1813. SSLCertificateFile /etc/ssl/certs/mydomainname.com.crt
  1814. SSLCertificateKeyFile /etc/ssl/private/mydomainname.com.key
  1815. # Options based on bettercrypto.org
  1816. SSLProtocol All -SSLv2 -SSLv3
  1817. SSLHonorCipherOrder On
  1818. SSLCompression off
  1819. 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
  1820. # SSL Engine Options:
  1821. # Set various options for the SSL engine.
  1822. # o FakeBasicAuth:
  1823. # Translate the client X.509 into a Basic Authorisation. This means that
  1824. # the standard Auth/DBMAuth methods can be used for access control. The
  1825. # user name is the `one line' version of the client's X.509 certificate.
  1826. # Note that no password is obtained from the user. Every entry in the user
  1827. # file needs this password: `xxj31ZMTZzkVA'.
  1828. # o ExportCertData:
  1829. # This exports two additional environment variables: SSL_CLIENT_CERT and
  1830. # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
  1831. # server (always existing) and the client (only existing when client
  1832. # authentication is used). This can be used to import the certificates
  1833. # into CGI scripts.
  1834. # o StdEnvVars:
  1835. # This exports the standard SSL/TLS related `SSL_*' environment variables.
  1836. # Per default this exportation is switched off for performance reasons,
  1837. # because the extraction step is an expensive operation and is usually
  1838. # useless for serving static content. So one usually enables the
  1839. # exportation for CGI and SSI requests only.
  1840. # o StrictRequire:
  1841. # This denies access when "SSLRequireSSL" or "SSLRequire" applied even
  1842. # under a "Satisfy any" situation, i.e. when it applies access is denied
  1843. # and no other module can change it.
  1844. # o OptRenegotiate:
  1845. # This enables optimized SSL connection renegotiation handling when SSL
  1846. # directives are used in per-directory context.
  1847. #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
  1848. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  1849. SSLOptions +StdEnvVars
  1850. </FilesMatch>
  1851. <Directory /usr/lib/cgi-bin>
  1852. SSLOptions +StdEnvVars
  1853. </Directory>
  1854. # SSL Protocol Adjustments:
  1855. # The safe and default but still SSL/TLS standard compliant shutdown
  1856. # approach is that mod_ssl sends the close notify alert but doesn't wait for
  1857. # the close notify alert from client. When you need a different shutdown
  1858. # approach you can use one of the following variables:
  1859. # o ssl-unclean-shutdown:
  1860. # This forces an unclean shutdown when the connection is closed, i.e. no
  1861. # SSL close notify alert is send or allowed to received. This violates
  1862. # the SSL/TLS standard but is needed for some brain-dead browsers. Use
  1863. # this when you receive I/O errors because of the standard approach where
  1864. # mod_ssl sends the close notify alert.
  1865. # o ssl-accurate-shutdown:
  1866. # This forces an accurate shutdown when the connection is closed, i.e. a
  1867. # SSL close notify alert is send and mod_ssl waits for the close notify
  1868. # alert of the client. This is 100% SSL/TLS standard compliant, but in
  1869. # practice often causes hanging connections with brain-dead browsers. Use
  1870. # this only for browsers where you know that their SSL implementation
  1871. # works correctly.
  1872. # Notice: Most problems of broken clients are also related to the HTTP
  1873. # keep-alive facility, so you usually additionally want to disable
  1874. # keep-alive for those clients, too. Use variable "nokeepalive" for this.
  1875. # Similarly, one has to force some clients to use HTTP/1.0 to workaround
  1876. # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
  1877. # "force-response-1.0" for this.
  1878. BrowserMatch "MSIE [2-6]" \
  1879. nokeepalive ssl-unclean-shutdown \
  1880. downgrade-1.0 force-response-1.0
  1881. # MSIE 7 and newer should be able to use keepalive
  1882. BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  1883. </VirtualHost>
  1884. </IfModule>
  1885. #+END_SRC
  1886. Enable your site with:
  1887. #+BEGIN_SRC: bash
  1888. a2ensite
  1889. #+END_SRC
  1890. then select the domain name and reload.
  1891. #+BEGIN_SRC: bash
  1892. service apache2 reload
  1893. #+END_SRC
  1894. and alter permissions:
  1895. #+BEGIN_SRC: bash
  1896. chmod -R 755 /var/www/$HOSTNAME/htdocs
  1897. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs
  1898. #+END_SRC
  1899. Open a browser and visit http://$HOSTNAME/install.php, then fill out the details. Once everything has been accepted without errors:
  1900. #+BEGIN_SRC: bash
  1901. rm /var/www/$HOSTNAME/htdocs/install.php
  1902. #+END_SRC
  1903. ** Install Owncloud
  1904. #+BEGIN_VERSE
  1905. /It's not water vapour/
  1906. -- Larry Ellison
  1907. #+END_VERSE
  1908. Owncloud will allow you to upload and download files, share photos, collaboratively edit documents, have a calendar and more. You should be warned that Owncloud runs quite slowly via an ordinary web browser, but it can be a convenient way to access and share your data from any location in a reasonably secure manner.
  1909. *** Server Installation
  1910. Install some dependencies:
  1911. #+BEGIN_SRC: bash
  1912. apt-get install apache2 php5 php5-gd php-xml-parser php5-intl
  1913. apt-get install php5-sqlite php5-mysql smbclient curl libcurl3 php5-curl
  1914. #+END_SRC
  1915. It's very important that /mod_php5/ and not /mod_php5filter/ be installed. If you have /mod_php5filter/ installed then Owncloud will always fail to install.
  1916. #+BEGIN_SRC: bash
  1917. a2dismod php5filter
  1918. apt-get install libapache2-mod-php5
  1919. #+END_SRC
  1920. Ensure that the size of files which may be uploaded or downloaded is large enough.
  1921. #+BEGIN_SRC: bash
  1922. emacs /etc/php5/apache2/php.ini
  1923. #+END_SRC
  1924. Set the following:
  1925. #+BEGIN_SRC: bash
  1926. upload_max_filesize = 512M
  1927. post_max_size = 512M
  1928. #+END_SRC
  1929. Save and exit, then edit your Apache configuration.
  1930. #+BEGIN_SRC: bash
  1931. export HOSTNAME=mydomainname.com
  1932. emacs /etc/apache2/sites-available/$HOSTNAME
  1933. #+END_SRC
  1934. And add the following, to the 443 VirtualHost section. Really we only will want to be using Owncloud with HTTPS to ensure some level of security and avoidance of dragnet surveillance.
  1935. #+BEGIN_SRC: bash
  1936. <Directory /var/www/mydomainname.com/htdocs/owncloud>
  1937. Options Indexes FollowSymLinks MultiViews
  1938. AllowOverride All
  1939. Order allow,deny
  1940. allow from all
  1941. </Directory>
  1942. #+END_SRC
  1943. To ensure that nobody logs in insecurely add the following to the 80 VirtualHost section.
  1944. #+BEGIN_SRC: bash
  1945. <Directory /var/www/mydomainname.com/htdocs/owncloud>
  1946. deny from all
  1947. </Directory>
  1948. #+END_SRC
  1949. Save and exit, then restart apache.
  1950. #+BEGIN_SRC: bash
  1951. service apache2 restart
  1952. #+END_SRC
  1953. Download owncloud.
  1954. #+BEGIN_SRC: bash
  1955. cd /tmp
  1956. wget http://freedombone.uk.to/owncloud.tar.bz2
  1957. #+END_SRC
  1958. Verify the download:
  1959. #+BEGIN_SRC: bash
  1960. md5sum owncloud.tar.bz2
  1961. f43eabb746b5e339ee70d0a6aaf4a49c
  1962. #+END_SRC
  1963. Extract the archive. This may take a couple of minutes, so don't be alarmed that the system has crashed.
  1964. #+BEGIN_SRC: bash
  1965. export HOSTNAME=mydomainname.com
  1966. tar -xjf owncloud.tar.bz2
  1967. #+END_SRC
  1968. Move the extracted files to your site and set file permissions.
  1969. #+BEGIN_SRC: bash
  1970. cp -r owncloud /var/www/$HOSTNAME/htdocs
  1971. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud/apps
  1972. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud/config
  1973. chown www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud
  1974. #+END_SRC
  1975. Edit the htaccess file for Owncloud.
  1976. #+BEGIN_SRC: bash
  1977. emacs /var/www/$HOSTNAME/htdocs/owncloud/.htaccess
  1978. #+END_SRC
  1979. Set the following.
  1980. #+BEGIN_SRC: bash
  1981. php_value upload_max_filesize 512M
  1982. php_value post_max_size 512M
  1983. php_value memory_limit 128M
  1984. #+END_SRC
  1985. Save and exit.
  1986. With a web browser visit your domain (mydomainname.com/owncloud) and enter an administrator username and password.
  1987. *** Owncloud on Android
  1988. First install [[https://f-droid.org/][F-Droid]] and then search for the current Owncloud app. Once it's installed you'll then be able to log into the BBB with the URL https://mydomainname.com/opencloud, supplying your username and password.
  1989. ** Install Bitmessage
  1990. #+BEGIN_VERSE
  1991. /Love your neighbour. Fight the future. If you are reading this you ARE the resistance./
  1992. -- BitChirp
  1993. #+END_VERSE
  1994. *** A new kind of Email
  1995. [[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.
  1996. 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.
  1997. Installing Bitmessage as a daemon will increase the size of the network, and therefore the level of security for all users.
  1998. *** The Daemon
  1999. Install from the current source code.
  2000. #+BEGIN_SRC: bash
  2001. apt-get install python screen
  2002. cd /tmp
  2003. git clone https://github.com/Bitmessage/PyBitmessage.git
  2004. cd PyBitmessage
  2005. make install
  2006. #+END_SRC
  2007. Now create the daemon.
  2008. #+BEGIN_SRC: bash
  2009. emacs /etc/init.d/pybitmessage
  2010. #+END_SRC
  2011. Add the following text:
  2012. #+BEGIN_SRC: bash
  2013. #!/bin/bash
  2014. # /etc/init.d/bitmessage
  2015. ### BEGIN INIT INFO
  2016. # Provides: pybitmessage
  2017. # Required-Start: $remote_fs $syslog
  2018. # Required-Stop: $remote_fs $syslog
  2019. # Default-Start: 2 3 4 5
  2020. # Default-Stop: 0 1 6
  2021. # Short-Description: starts bitmessage as a background daemon, suitable for servers
  2022. # Description: This file should be used to construct scripts to be
  2023. # placed in /etc/init.d.
  2024. ### END INIT INFO
  2025. # Author: Super-Nathan <BM-Gu2k3Wy2hpTMYBxSoM2937SPcuU6xzEj>
  2026. #Settings
  2027. SERVICE='pybitmessage'
  2028. LOGFILE='/dev/null' # this disables logging
  2029. # LOGFILE='/var/log/bitmessage.log' # comment out the above line and un-comment this line to save a log
  2030. COMMAND="python bitmessagemain.py > $LOGFILE"
  2031. USERNAME='bitmsg'
  2032. NICELEVEL=19 # from 0-19 the bigger the number, the less the impact on system resources
  2033. HISTORY=1024
  2034. PBM_LOCATION="/usr/local/share/pybitmessage"
  2035. INVOCATION="nice -n ${NICELEVEL} ${COMMAND}"
  2036. PATH='/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl:/sbin:/usr/sbin:/bin:/usr/local/share/pybitmessage'
  2037. bm_start() {
  2038. echo "Starting $SERVICE..."
  2039. cd ${PBM_LOCATION}
  2040. su --command "screen -h ${HISTORY} -dmS ${SERVICE} ${INVOCATION}" $USERNAME
  2041. }
  2042. bm_stop() {
  2043. echo "Stopping $SERVICE"
  2044. su --command "screen -p 0 -S ${SERVICE} -X stuff "'^C'"" $USERNAME
  2045. }
  2046. #Start-Stop here
  2047. case "$1" in
  2048. start)
  2049. bm_start
  2050. ;;
  2051. stop)
  2052. bm_stop
  2053. ;;
  2054. restart)
  2055. bm_stop
  2056. sleep 60s
  2057. bm_start
  2058. ;;
  2059. *)
  2060. echo "Usage: $0 {start|stop|restart}"
  2061. exit 1
  2062. ;;
  2063. esac
  2064. exit 0
  2065. #+END_SRC
  2066. Save and exit.
  2067. 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.
  2068. #+BEGIN_SRC: bash
  2069. adduser bitmsg
  2070. #+END_SRC
  2071. Create a /keys.dat/ file which is used to configure Bitmessage.
  2072. #+BEGIN_SRC: bash
  2073. mkdir /home/bitmsg/.config
  2074. mkdir /home/bitmsg/.config/PyBitmessage
  2075. emacs /home/bitmsg/.config/PyBitmessage/keys.dat
  2076. #+END_SRC
  2077. Add the following:
  2078. #+BEGIN_SRC: bash
  2079. [bitmessagesettings]
  2080. settingsversion = 7
  2081. port = 8444
  2082. timeformat = %%a, %%d %%b %%Y %%I:%%M %%p
  2083. blackwhitelist = black
  2084. startonlogon = false
  2085. minimizetotray = false
  2086. showtraynotifications = false
  2087. startintray = false
  2088. socksproxytype = none
  2089. sockshostname = localhost
  2090. socksport = 9050
  2091. socksauthentication = false
  2092. sockslisten = false
  2093. socksusername =
  2094. sockspassword =
  2095. keysencrypted = false
  2096. messagesencrypted = false
  2097. defaultnoncetrialsperbyte = 640
  2098. defaultpayloadlengthextrabytes = 14000
  2099. minimizeonclose = false
  2100. maxacceptablenoncetrialsperbyte = 0
  2101. maxacceptablepayloadlengthextrabytes = 0
  2102. userlocale = system
  2103. namecoinrpctype = namecoind
  2104. namecoinrpchost = localhost
  2105. namecoinrpcuser =
  2106. namecoinrpcpassword =
  2107. namecoinrpcport = 8336
  2108. sendoutgoingconnections = True
  2109. daemon = true
  2110. #+END_SRC
  2111. Save and exit. Then enable the daemon and run it.
  2112. #+BEGIN_SRC: bash
  2113. rm -f /tmp/-usr-local-share-pybitmessage-*.lock
  2114. chown -R bitmsg:bitmsg /home/bitmsg
  2115. chmod +x /etc/init.d/pybitmessage
  2116. update-rc.d pybitmessage defaults
  2117. service pybitmessage start
  2118. #+END_SRC
  2119. Now open port 8444 on your internet router or firewall and direct it to the BBB.
  2120. *** Using Bitmessage
  2121. Although in principle it would be possible to send Bitmessages directly from the BBB, in practice the /proof of work/ requirement would mean that it would take an infeasibly long time to send messages, and the computational workload would likely greatly impair the performance of other services also running on the system. So to send and receive Bitmessages it's better to just install the client on a laptop or desktop machine.
  2122. The easiest way to install the client is either to download it from [[https://bitmessage.org][bitmessage.org]] or to get the latest build from Github as follows:
  2123. #+BEGIN_SRC: bash
  2124. cd /tmp
  2125. git clone https://github.com/Bitmessage/PyBitmessage.git
  2126. cd PyBitmessage
  2127. make install
  2128. pybitmessage
  2129. #+END_SRC
  2130. ** Install Tripwire
  2131. #+BEGIN_VERSE
  2132. /...by the time you get done with all of that, we have a freedom box/
  2133. -- Eben Moglen
  2134. #+END_VERSE
  2135. 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.
  2136. #+BEGIN_SRC: bash
  2137. apt-get install tripwire
  2138. export HOSTNAME=mydomainname.com
  2139. cd /etc/tripwire
  2140. cp arm-local.key $HOSTNAME-local.key
  2141. cp site.key $HOSTNAME-site.key
  2142. tripwire --init
  2143. tripwire --update-policy --secure-mode low /etc/tripwire/twpol.txt
  2144. tripwire --check --interactive
  2145. #+END_SRC
  2146. you will be asked for two passphrases ("site" and "local"). Make a note of these.
  2147. If you subsequently install any more packages or make configuration changes then update the policy again with:
  2148. #+BEGIN_SRC: bash
  2149. tripwire --update-policy --secure-mode low /etc/tripwire/twpol.txt
  2150. #+END_SRC
  2151. Also, to look for any rootkits.
  2152. #+BEGIN_SRC: bash
  2153. apt-get install rkhunter
  2154. #+END_SRC
  2155. * Router/Firewall ports
  2156. The following ports on your internet router/firewall should be forwarded to the BBB.
  2157. | Protocol | Port/s |
  2158. |---------------+------------|
  2159. | Gopher | 70 |
  2160. | HTTP | 80 |
  2161. | HTTPS | 443 |
  2162. | IMAP | 143 |
  2163. | IRC SSL | 6670 |
  2164. | SIP | 5060..5061 |
  2165. | SMTP | 25 |
  2166. | SMTPS | 465 |
  2167. | SSH | 22 |
  2168. | XMPP | 5222..5223 |
  2169. | XMPP (server) | 5269 |
  2170. | Bitmessage | 8444 |
  2171. * Hints and Tips
  2172. ** Messaging security
  2173. 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.
  2174. ** Restrictive/hostile user environments
  2175. 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:
  2176. http://www.coralbits.com/oterm/
  2177. https://github.com/davidmoreno/onion
  2178. ** Moving Domains
  2179. 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:
  2180. #+BEGIN_SRC: bash
  2181. find /var/www/mynewdomain/htdocs -type f -exec sed -i 's@myolddomain@mynewdomain@g' {} \;
  2182. #+END_SRC
  2183. ** MySql foo
  2184. *** Backup all databases
  2185. To back up all mysql databases:
  2186. #+BEGIN_SRC: bash
  2187. mysqldump -u root -p --all-databases --events > /var/backups/databasebackup.sql
  2188. #+END_SRC
  2189. *** Restoring a particular mysql database
  2190. To restore yesterday's friendica backup:
  2191. #+BEGIN_SRC: bash
  2192. mysql -D friendica -o < /var/backups/friendica_daily.sql
  2193. #+END_SRC
  2194. To restore yesterday's mediawiki backup:
  2195. #+BEGIN_SRC: bash
  2196. mysql -D wikidb -o < /var/backups/wikidb_daily.sql
  2197. #+END_SRC
  2198. *** Removing mysql server
  2199. If you manage to screw up sql server completely then it can be fully deleted with:
  2200. #+BEGIN_SRC: bash
  2201. ps aux | grep mysql
  2202. #+END_SRC
  2203. and use /kill -9 <pid>/ to kill all mysql processes.
  2204. #+BEGIN_SRC: bash
  2205. apt-get remove --purge mysql\*
  2206. apt-get clean
  2207. updatedb
  2208. #+END_SRC