beaglebone.txt 136KB

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