beaglebone.txt 131KB

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