beaglebone.txt 105KB

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