beaglebone.txt 117KB

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