beaglebone.txt 181KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754
  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. #+ATTR_HTML: image :align right
  12. [[./images/freedombone_small.jpg]]
  13. #+BEGIN_CENTER
  14. Copyright (C) 2014 Bob Mottram
  15. Permission is granted to copy, distribute and/or modify this document under the terms of the [[https://gnu.org/licenses/fdl.html][GNU Free Documentation License]], Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
  16. Source for this web site in [[https://en.wikipedia.org/wiki/Org-mode][Emacs org-mode]] format is available [[/beaglebone.txt][here]]. Comments or patches may be submitted via [[https://github.com/fuzzgun/freedombone][Github]].
  17. #+END_CENTER
  18. * Introduction
  19. #+BEGIN_VERSE
  20. /If you look at it from an engineering perspective, an iterative perspective, it’s clear that you have to try something rather than do nothing./
  21. -- Edward J. Snowden
  22. #+END_VERSE
  23. ** What is FreedomBone?
  24. Today many of us rely upon "free" services in the cloud, such as Gmail, Facebook, Google+ and so on. It might appear that these services are indispensible infrastructure of the modern internet, but actually they're not strictly needed and the amount of value which they deliver to the average internet user is very marginal. It is possible to be a citizen of the internet and yet not use those things - to disintermediate the most well known companies and cut out their prurient or merely cringeworthy business models.
  25. FreedomBone is a personal home communications server based upon the BeagleBone Black hardware. It's small and cheap and will allow you to use email, have your own web site and do social networking in a federated way without needing to rely upon any intermediary companies other than your ISP.
  26. ** Do I need any prior knowledge?
  27. In these instructions only a minimal level of familiarity with Linux is assumed. It's assumed that you know the basics of the /nano/ and /emacs/ editors, but it would be simple to also use other editors if you prefer.
  28. ** Why should I do this?
  29. You should consider doing this if you are a freedom-oriented sort of person and you want to maintain sovereignty over your information. Laws in many places in the world consider you to have relinquished any property rights over data which you put onto a server not owned by youself (i.e. owned by a third party, such as Google or Facebook).
  30. If you don't like the idea of having all your communications intercepted and investigated by the Surveillance State then you should consider running a FreedomBone. If your profession involves maintaining confidentiality as an essential feature, such as legal or medical services, counselling, teaching or any sort of activism then you should consider running a FreedomBone.
  31. As Eben Moglen noted in his now famous [[https://www.youtube.com/watch?v=QOEMv0S8AcA]["Freedom in The Cloud"]] talk the simple fact of you keeping your own internet logs (found in the /var/log directory) puts a certain amount of power in your hands and takes it away from parties who would otherwise sell that information without your knowledge or permission to advertisers or other shady outfits who may not have your best interests at heart.
  32. ** After it's installed will it need a lot of maintenance?
  33. So long as the hardware is ok the amount of maintenance needed should be very small. Unlike on Windows based systems you don't need to defragment drives or mess about with anti-virus programs. I ran a similar Sheevaplug system between 2010 and 2013 with only occasional software updates or reboots, and uptime was probably 99% or better.
  34. ** Is it secure?
  35. Nothing is totally secure or infallible. You could have the most secure technology and yet still use easy to guess passwords. This system will not defend you from an attacker who is actively trying to block or corrupt your communications, but I assume that doesn't apply in the majority of cases. Another thing to be aware of is that running a FreedomBone could make you more vulnerable to traffic analysis, since the server is associated with your home address and isn't a giant aggregation of users somewhere in the cloud. You need to weigh this alongside the additional legal protection which owning the server and having it in your own home gives you.
  36. FreedomBone should be far more secure than using popular cloud-based services which have spying built into them as a core feature (although not one which is typically advertised), but it is not necessarily an impenetrable information fortress. This project is at least as much about achieving communications independence as it is about being able to do that securely.
  37. ** Will running a server all the time affect my electricity bill?
  38. Hardly at all. The BeagleBone Black consumes very little power - less than 5W. It would even be potentially possible to run it from a solar panel.
  39. ** Can I use a Raspberry Pi or Cubieboard instead?
  40. These instructions are not highly specific to the Beaglebone Black and so will likely also work on other single board computers (SBCs) such as the [[https://en.wikipedia.org/wiki/Raspberry_pi][Raspberry Pi]] or [[https://en.wikipedia.org/wiki/Cubieboard][Cubieboard]]. The original Raspberry Pi only had 256MB of RAM and so the performance of some services may be more limited. The Beaglebone Black was chosen mainly because of its low cost, relatively good CPU performance for the price (by the standards of 2013) and also low electricity consumption. The Cubieboard is also another good alternative, with the A20 version having similar specifications but twice as much RAM as the BeagleBone Black.
  41. ** Why should I trust the packages or source code downloaded from this site?
  42. If you're particularly security conscious then you shouldn't. Binary or source packages have only been included here for convenience and to avoid confusion. "/Go and find a Debian installation for the BeagleBone Black somewhere on the web/" is too vague an instruction for my liking, and I've attempted to keep things as concise and unambiguous as possible - particularly with an average or new Linux user in mind.
  43. However, for maximum security for those software systems which are not already packaged within the Debian repositories then seek out the original sources and verify the hashes independently.
  44. It's worth adopting an attitude of "/trust but verify/". Don't let fear of mass surveillance and [[https://www.techdirt.com/articles/20140207/08354426130/gchq-has-entire-program-dirty-tricks-including-honeypots-using-journalists-deleting-online-accounts.shtml]["dirty tricks"]] paralyse you into trusting nothing and consequently doing nothing. Doing nothing means that the surveillance apparatus has succeeded in keeping you under observation at all times.
  45. * Inventory
  46. #+BEGIN_VERSE
  47. /You can’t help someone just by making a wish to do so, you have to take action./
  48. -- Dalai Lama
  49. #+END_VERSE
  50. These instructions assume that you have the following ingredients.
  51. ** A BeagleBone Black (BBB)
  52. 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.
  53. ** An internet connection
  54. 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.
  55. ** microSD card
  56. 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.
  57. 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.
  58. ** 5V/2A power supply
  59. 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. One way to test whether the board has enough power is to try compiling a Linux kernel on it, but any CPU and disk intensive program will also suffice as a test.
  60. [[http://beagleboard.org/Support/FAQ][beagleboard.org]] gives the following advice on power supplies:
  61. #+BEGIN_VERSE
  62. /Power over USB is sufficient as long as the software and system running perform some management to keep it under the USB current limit threshold. For simplicity and maximum capability, powering over the 5V barrel connector is typically recommended./
  63. /The power adapter is required to provide 5V over a 5.5mm outer diameter and 2.1mm inner diameter barrel connector (a barrel connector length of 9.5mm is more than sufficient). The recommended supply current is at least 1.2A (or 6W), but at least 2A (or 10W) is recommended if you are going to connect up anything over the USB./
  64. #+END_VERSE
  65. The plug should be /centre positive/, meaning that the centre/tip is positive and the outer part is negative.
  66. ** An ethernet patch cable
  67. Just an ordinary cat5 or cat6 cable that you can get from most electrical/computer stores.
  68. * Installing Debian onto the microSD card
  69. 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.
  70. Download the image.
  71. #+BEGIN_SRC: bash
  72. cd ~/
  73. wget http://freedombone.uk.to/debian-7.2-console-armhf-2013-11-15.tar.xz
  74. #+END_SRC
  75. Verify it.
  76. #+BEGIN_SRC: bash
  77. sha256sum debian-7.2-console-armhf-2013-11-15.tar.xz
  78. 262ea96d6bff530ad545e001eb2aa50b26a999c02f0c0e2e5f8536edf21c973a debian-7.2-console-armhf-2013-11-15.tar.xz
  79. #+END_SRC
  80. Uncompress it.
  81. #+BEGIN_SRC: bash
  82. tar xJf debian-7.2-console-armhf-2013-11-15.tar.xz
  83. cd debian-7.2-console-armhf-2013-11-15
  84. #+END_SRC
  85. Create the disk image, where sdX is the name of the flash drive (probably it will be sdb or sdc).
  86. #+BEGIN_SRC: bash
  87. sudo apt-get install u-boot-tools
  88. sudo ./setup_sdcard.sh --mmc /dev/sdX --uboot bone --swap-file 1024
  89. #+END_SRC
  90. Once completed then safely remove the microSD card via your file manager (usually right click and "safely remove" or "eject").
  91. * Setup
  92. #+BEGIN_VERSE
  93. /Build the tools for a future you would want to live in/
  94. -- Kurt Opsahl
  95. #+END_VERSE
  96. ** Things to be aware of
  97. *** A note on ssh
  98. 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:
  99. #+BEGIN_SRC: bash
  100. ssh-keygen -R <IP address>
  101. #+END_SRC
  102. *** Passwords
  103. 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.
  104. *** HTTPS
  105. 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..
  106. 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.
  107. ** Initial
  108. Plug the microSD card into the BBB and Connect the USB cable to your laptop/desktop, then login via ssh.
  109. #+BEGIN_SRC: bash
  110. ssh debian@192.168.7.2
  111. #+END_SRC
  112. The default password is /temppwd/
  113. Then log in as root:
  114. #+BEGIN_SRC: bash
  115. su
  116. #+END_SRC
  117. The default password is /root/
  118. The first thing to do is to change the passwords from their defaults.
  119. #+BEGIN_SRC: bash
  120. passwd
  121. #+END_SRC
  122. 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.
  123. #+BEGIN_SRC: bash
  124. nano /etc/network/interfaces
  125. #+END_SRC
  126. The resulting interfaces file should look like this:
  127. #+BEGIN_SRC: bash
  128. # This file describes the network interfaces available on your system
  129. # and how to activate them. For more information, see interfaces(5).
  130. # The loopback network interface
  131. auto lo
  132. iface lo inet loopback
  133. # The primary network interface
  134. allow-hotplug eth0
  135. iface eth0 inet static
  136. address 192.168.1.60
  137. netmask 255.255.255.0
  138. gateway 192.168.1.254
  139. dns-nameservers 213.73.91.35 85.214.20.141
  140. # Example to keep MAC address between reboots
  141. #hwaddress ether DA:AD:CE:EF:CA:FE
  142. # WiFi Example
  143. #auto wlan0
  144. #iface wlan0 inet dhcp
  145. # wpa-ssid "essid"
  146. # wpa-psk "password"
  147. # Ethernet/RNDIS gadget (g_ether)
  148. # ... or on host side, usbnet and random hwaddr
  149. # Note on some boards, usb0 is automaticly setup with an init script
  150. # in that case, to completely disable remove file [run_boot-scripts] from the boot partition
  151. #iface usb0 inet static
  152. # address 192.168.7.2
  153. # netmask 255.255.255.0
  154. # network 192.168.7.0
  155. # gateway 192.168.7.1
  156. #+END_SRC
  157. CTRL-O followed by ENTER to save, then CTRL-X to exit.
  158. 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.
  159. "gateway 192.168.1.254" should be the IP address of the router.
  160. Note that setting the DNS servers with dns-nameservers is important because some home routers do not allow you to change the DNS settings.
  161. Edit resolv.conf.
  162. #+BEGIN_SRC: bash
  163. nano /etc/resolv.conf
  164. #+END_SRC
  165. It should look something like the following:
  166. #+BEGIN_SRC: bash
  167. domain localdomain
  168. search localdomain
  169. nameserver 213.73.91.35
  170. nameserver 85.214.20.141
  171. #+END_SRC
  172. CTRL-O followed by ENTER to save, then CTRL-X to exit.
  173. 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.
  174. 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".
  175. ** Add a user
  176. Ssh back in to the BBB and login as root. In this example the BBB's IP address is 192.168.1.60.
  177. #+BEGIN_SRC: bash
  178. ssh-keygen -f "/home/myusername/.ssh/known_hosts" -R 192.168.1.60
  179. ssh debian@192.168.1.60
  180. su
  181. #+END_SRC
  182. 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.
  183. #+BEGIN_SRC: bash
  184. adduser myusername
  185. #+END_SRC
  186. 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.
  187. Remove the default debian user.
  188. #+BEGIN_SRC: bash
  189. userdel -r debian
  190. #+END_SRC
  191. ** Text editor
  192. For an editor which is less erratic than vi when used within a remote console such as Terminator.
  193. #+BEGIN_SRC: bash
  194. apt-get update
  195. apt-get install emacs
  196. #+END_SRC
  197. Some basic Emacs keys which will be useful to new users are:
  198. | Load a file | CTRL-x CTRL-f |
  199. | Save | CTRL-x CTRL-s |
  200. | Exit | CTRL-x CTRL-c |
  201. ** Create a swap file
  202. 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:
  203. #+BEGIN_SRC: bash
  204. mkdir -p /var/cache/swap/
  205. dd if=/dev/zero of=/var/cache/swap/swapfile bs=1M count=1024
  206. chmod 600 /var/cache/swap/swapfile
  207. mkswap /var/cache/swap/swapfile
  208. swapon /var/cache/swap/swapfile
  209. #+END_SRC
  210. To tell the OS to load this swapfile on each start up.
  211. #+BEGIN_SRC: bash
  212. emacs /etc/fstab
  213. #+END_SRC
  214. Append the following line:
  215. #+BEGIN_SRC: bash
  216. /var/cache/swap/swapfile none swap sw 0 0
  217. #+END_SRC
  218. Then save and exit.
  219. 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.
  220. ** Enable backports
  221. To enable some newer packages add backports to the repositories.
  222. #+BEGIN_SRC: bash
  223. echo "deb http://ftp.us.debian.org/debian wheezy-backports main" >> /etc/apt/sources.list
  224. apt-get update
  225. apt-get dist-upgrade
  226. #+END_SRC
  227. ** Random number generation
  228. #+BEGIN_VERSE
  229. /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./
  230. -- Bruce Schneier, on the 2013 leaked NSA documents
  231. #+END_VERSE
  232. 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.
  233. 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:
  234. #+BEGIN_SRC: bash
  235. apt-get install haveged
  236. #+END_SRC
  237. 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.
  238. ** Alter ssh configuration
  239. Altering the ssh configuration will make it a little more secure than the standard Debian settings.
  240. #+BEGIN_SRC: bash
  241. emacs /etc/ssh/sshd_config
  242. #+END_SRC
  243. Check the following values:
  244. #+BEGIN_SRC: bash
  245. PermitRootLogin no
  246. X11Forwarding no
  247. ServerKeyBits 4096
  248. Protocol 2
  249. PermitEmptyPasswords no
  250. StrictModes yes
  251. #+END_SRC
  252. Append the following:
  253. #+BEGIN_SRC: bash
  254. Ciphers aes256-ctr,aes192-ctr,aes128-ctr
  255. MACs hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
  256. KexAlgorithms diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1
  257. #+END_SRC
  258. CTRL-X CTRL-S to save, then CTRL-X CTRL-C to exit.
  259. #+BEGIN_SRC: bash
  260. service ssh restart
  261. #+END_SRC
  262. To test the new settings log out by typing "exit" a couple of times, then log back in again with:
  263. #+BEGIN_SRC: bash
  264. ssh -vvv myusername@192.168.1.60
  265. #+END_SRC
  266. and check that some number of bits are set within a 4096 bit sized key:
  267. #+BEGIN_SRC: bash
  268. debug2: bits set: */4096
  269. #+END_SRC
  270. ** Getting onto the web
  271. 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.
  272. Select "/dynamic DNS/" then click "/quick cron example/"
  273. An example would look like:
  274. #+BEGIN_SRC: bash
  275. 4,9,14,19,24,29,34,39,44,49,54,59 * * * * root sleep 29 ; /usr/bin/timeout 120 wget -O - http://free\ dns.afraid.org/dynamic/update.php?ABCKDNRCLFHENSLKNFEGSBFLFF== >> /\ tmp/freedns_mysubdomain_us_to.log 2>&1 &
  276. #+END_SRC
  277. Edit */etc/crontab* and append that to the end of the file.
  278. 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.
  279. The freeDNS subdomain which you just created will hereafter just be refered to as "/your domain name/".
  280. ** Set the host name
  281. #+BEGIN_SRC: bash
  282. emacs /etc/hostname
  283. #+END_SRC
  284. CTRL-x CTRL-s to save, then CTRL-x CTRL-c to exit.
  285. Also issue the command, replacing /mydomainname.com/ with your domain name.
  286. #+BEGIN_SRC: bash
  287. hostname mydomainname.com
  288. #+END_SRC
  289. You may also need to assign the same hostname separately via your router's web interface.
  290. #+BEGIN_SRC: bash
  291. emacs /etc/hosts
  292. #+END_SRC
  293. Append the following, replacing /mydomainname.com/ with your domain name.
  294. #+BEGIN_SRC: bash
  295. 127.0.1.1 mydomainname.com
  296. #+END_SRC
  297. If you then run the command:
  298. #+BEGIN_SRC: bash
  299. hostname -f
  300. #+END_SRC
  301. it should return your domain name.
  302. ** Install NTP
  303. To synchronise time.
  304. #+BEGIN_SRC: bash
  305. apt-get install ntp
  306. #+END_SRC
  307. ** Install fail2ban
  308. #+BEGIN_SRC: bash
  309. apt-get install fail2ban
  310. #+END_SRC
  311. ** Set up a firewall
  312. #+BEGIN_VERSE
  313. /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/
  314. -- NBC News article: /War on Anonymous: British Spies Attacked Hackers, Snowden Docs Show/
  315. #+END_VERSE
  316. A basic firewall limits the maximum rate at which connections can be made and closes any unused ports, and this helps to defend against various kinds of DDOS attack.
  317. #+BEGIN_SRC: bash
  318. apt-get install portsentry
  319. emacs /etc/portsentry/portsentry.conf
  320. #+END_SRC
  321. Uncomment the entry for *iptables support for Linux*
  322. Set the following properties:
  323. #+BEGIN_SRC: bash
  324. TCP_PORTS="1,7,9,11,15,79,109,110,111,119,138,139,512,513,514,515,540,635,1080,1524,2000,2001,4000,4001,5742,6000,6001,6667,12345,12346,20034,27665,30303,32771,32772,32773,32774,31337,40421,40425,49724,54320"
  325. UDP_PORTS="1,7,9,66,67,68,69,111,137,138,161,162,474,513,517,518,635,640,641,666,700,2049,31335,27444,34555,32770,32771,32772,32773,32774,31337,54321"
  326. ADVANCED_EXCLUDE_TCP="113,139,70,80,443,143,6670,993,5060,5061,25,465,22,5222,5223,5269,5280,5281,8444"
  327. ADVANCED_EXCLUDE_UDP="520,138,137,67,70,80,443,143,6670,993, 5060,5061,25,465,22,5222,5223,5269,5280,5281,8444"
  328. SCAN_TRIGGER="2"
  329. BLOCK_UDP="2"
  330. BLOCK_TCP="2"
  331. #+END_SRC
  332. Save and exit.
  333. #+BEGIN_SRC: bash
  334. service portsentry restart
  335. emacs /tmp/firewall.sh
  336. #+END_SRC
  337. Enter the following:
  338. #+BEGIN_SRC: bash
  339. #!/bin/bash
  340. # Enable syn cookies
  341. echo 1 > /proc/sys/net/ipv4/tcp_syncookies
  342. # Other settings
  343. echo 1 > /proc/sys/net/ipv4/tcp_keepalive_probes
  344. echo 2 > /proc/sys/net/ipv4/tcp_synack_retries
  345. echo 1 > /proc/sys/net/ipv4/tcp_syn_retries
  346. # First of all delete any existing rules.
  347. # This means you're back to a known state:
  348. iptables -P INPUT ACCEPT
  349. ip6tables -P INPUT ACCEPT
  350. iptables -F
  351. ip6tables -F
  352. iptables -X
  353. ip6tables -X
  354. # Drop any IPv6 traffic
  355. ip6tables -A INPUT -p icmp -j DROP
  356. ip6tables -A INPUT -p tcp -j DROP
  357. ip6tables -A INPUT -p udp -j DROP
  358. # Drop access to unused ports
  359. iptables -A INPUT -p tcp --destination-port 1 -j DROP
  360. iptables -A INPUT -p tcp --destination-port 7 -j DROP
  361. iptables -A INPUT -p tcp --destination-port 109:111 -j DROP
  362. iptables -A INPUT -p tcp --destination-port 995 -j DROP
  363. iptables -A INPUT -p tcp --destination-port 139 -j DROP
  364. iptables -A INPUT -p tcp --destination-port 6000:6001 -j DROP
  365. iptables -A INPUT -p tcp --destination-port 9 -j DROP
  366. iptables -A INPUT -p tcp --destination-port 79 -j DROP
  367. iptables -A INPUT -p tcp --destination-port 515 -j DROP
  368. iptables -A INPUT -p tcp --destination-port 4001 -j DROP
  369. iptables -A INPUT -p tcp --destination-port 1524 -j DROP
  370. iptables -A INPUT -p tcp --destination-port 1080 -j DROP
  371. iptables -A INPUT -p tcp --destination-port 512:514 -j DROP
  372. iptables -A INPUT -p tcp --destination-port 31337 -j DROP
  373. iptables -A INPUT -p tcp --destination-port 2000:2001 -j DROP
  374. iptables -A INPUT -p tcp --destination-port 12345 -j DROP
  375. iptables -A INPUT -p tcp --destination-port 32771:32774 -j DROP
  376. iptables -A INPUT -p tcp --destination-port 4000 -j DROP
  377. iptables -A INPUT -p tcp --destination-port 119 -j DROP
  378. iptables -A INPUT -p tcp --destination-port 137 -j DROP
  379. iptables -A INPUT -p udp --destination-port 1 -j DROP
  380. iptables -A INPUT -p udp --destination-port 7 -j DROP
  381. iptables -A INPUT -p udp --destination-port 109:111 -j DROP
  382. iptables -A INPUT -p udp --destination-port 995 -j DROP
  383. iptables -A INPUT -p udp --destination-port 139 -j DROP
  384. iptables -A INPUT -p udp --destination-port 6000:6001 -j DROP
  385. iptables -A INPUT -p udp --destination-port 9 -j DROP
  386. iptables -A INPUT -p udp --destination-port 79 -j DROP
  387. iptables -A INPUT -p udp --destination-port 515 -j DROP
  388. iptables -A INPUT -p udp --destination-port 4001 -j DROP
  389. iptables -A INPUT -p udp --destination-port 1524 -j DROP
  390. iptables -A INPUT -p udp --destination-port 1080 -j DROP
  391. iptables -A INPUT -p udp --destination-port 512:514 -j DROP
  392. iptables -A INPUT -p udp --destination-port 31337 -j DROP
  393. iptables -A INPUT -p udp --destination-port 2000:2001 -j DROP
  394. iptables -A INPUT -p udp --destination-port 12345 -j DROP
  395. iptables -A INPUT -p udp --destination-port 32771:32774 -j DROP
  396. iptables -A INPUT -p udp --destination-port 4000 -j DROP
  397. iptables -A INPUT -p udp --destination-port 119 -j DROP
  398. iptables -A INPUT -p udp --destination-port 137 -j DROP
  399. # Make sure NEW incoming tcp connections are SYN packets
  400. iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
  401. # Drop packets with incoming fragments
  402. iptables -A INPUT -f -j DROP
  403. # Incoming malformed XMAS packets drop them
  404. iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
  405. iptables -A INPUT -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP
  406. iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
  407. # Incoming malformed NULL packets:
  408. iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
  409. # Drop UDP to used ports
  410. iptables -A INPUT -p udp --match multiport --dports 70,80,443,143,6670,993,5060,5061,25 -j DROP
  411. iptables -A INPUT -p udp --match multiport --dports 465,22,5222,5223,5269,5280,5281,8444 -j DROP
  412. # Limit ssh logins
  413. iptables -A INPUT -p tcp --dport 22 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  414. # Limit web connections
  415. iptables -A INPUT -p tcp --dport 80 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  416. iptables -A INPUT -p tcp --dport 443 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  417. # Limit number of XMPP connections
  418. iptables -A INPUT -p tcp --match multiport --dports 5222:5223,5269,5280:5281 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  419. # Limit IRC connections
  420. iptables -A INPUT -p tcp --dport 6666:6670 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  421. # Limit gopher connections
  422. iptables -A INPUT -p tcp --dport 70 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  423. # Limit IMAP connections
  424. iptables -A INPUT -p tcp --dport 143 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  425. iptables -A INPUT -p tcp --dport 993 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  426. # Limit SIP connections
  427. iptables -A INPUT -p tcp --dport 5060:5061 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  428. # Limit SMTP/SMTPS connections
  429. iptables -A INPUT -p tcp --dport 25 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  430. iptables -A INPUT -p tcp --dport 465 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  431. # Limit Bitmessage connections
  432. iptables -A INPUT -p tcp --dport 8444 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  433. # Limit the number of incoming tcp connections
  434. # Interface 0 incoming syn-flood protection
  435. iptables -N syn_flood
  436. iptables -A INPUT -p tcp --syn -j syn_flood
  437. iptables -A syn_flood -m limit --limit 1/s --limit-burst 3 -j RETURN
  438. iptables -A syn_flood -j DROP
  439. # Limiting the incoming icmp ping request:
  440. #iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 1 -j ACCEPT
  441. #iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 1 -j LOG --log-prefix PING-DROP:
  442. iptables -A INPUT -p icmp -j DROP
  443. #iptables -A OUTPUT -p icmp -j ACCEPT
  444. # Save the settings
  445. iptables-save > /etc/firewall.conf
  446. ip6tables-save > /etc/firewall6.conf
  447. printf '#!/bin/sh\n' > /etc/network/if-up.d/iptables
  448. printf 'iptables-restore < /etc/firewall.conf\n' >> /etc/network/if-up.d/iptables
  449. printf 'ip6tables-restore < /etc/firewall6.conf\n' >> /etc/network/if-up.d/iptables
  450. chmod +x /etc/network/if-up.d/iptables
  451. #+END_SRC
  452. Save and exit.
  453. Note that this will disable IP version 6. At the time of writing it is expected that the average internet user is running on IP version 4.
  454. #+BEGIN_SRC: bash
  455. chmod +x /tmp/firewall.sh
  456. . /tmp/firewall.sh
  457. rm /tmp/firewall.sh
  458. #+END_SRC
  459. Also disable ping. This may be inconvenient to some extent, but it seems common for malicious systems, including but not limited to the [[http://www.nbcnews.com/news/investigations/snowden-docs-british-spies-used-sex-dirty-tricks-n23091][JTRIG "EFFECTS" team]], to try to disable the machine by flooding it with pings. These days there seems to be not much difference between "cybercrime" and nefarious state-sponsored internet activities.
  460. #+BEGIN_SRC: bash
  461. emacs /etc/sysctl.conf
  462. #+END_SRC
  463. Uncomment or change the following:
  464. #+BEGIN_SRC: bash
  465. net.ipv4.conf.all.accept_redirects = 0
  466. net.ipv6.conf.all.accept_redirects = 0
  467. net.ipv4.conf.all.send_redirects = 0
  468. net.ipv4.conf.all.accept_source_route = 0
  469. net.ipv6.conf.all.accept_source_route = 0
  470. net.ipv4.conf.default.rp_filter=1
  471. net.ipv4.conf.all.rp_filter=1
  472. net.ipv4.ip_forward=0
  473. net.ipv6.conf.all.forwarding=0
  474. #+END_SRC
  475. And append the following:
  476. #+BEGIN_SRC: bash
  477. # ignore pings
  478. net.ipv4.icmp_echo_ignore_all = 1
  479. # disable ipv6
  480. net.ipv6.conf.all.disable_ipv6 = 1
  481. #+END_SRC
  482. 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:
  483. #+BEGIN_SRC: bash
  484. reboot
  485. #+END_SRC
  486. After reboot and logging back in to the root account via /ssh/ you can verify that the firewall rules were restored correctly with:
  487. #+BEGIN_SRC: bash
  488. iptables -L
  489. #+END_SRC
  490. and
  491. #+BEGIN_SRC: bash
  492. ip6tables -L
  493. #+END_SRC
  494. ** Install Email
  495. #+BEGIN_VERSE
  496. /If you knew what I know about email, you might not use it/
  497. -- Ladar Levison
  498. #+END_VERSE
  499. 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.
  500. Exim4 seems much easier to install and configure than Postfix.
  501. #+BEGIN_SRC: bash
  502. aptitude install exim4 sasl2-bin swaks libnet-ssleay-perl procmail
  503. #+END_SRC
  504. You will be prompted to remove postfix. Say yes and yes again.
  505. #+BEGIN_SRC: bash
  506. dpkg-reconfigure exim4-config
  507. #+END_SRC
  508. Settings as follows:
  509. #+BEGIN_SRC: bash
  510. internet site
  511. System mail name: mydomainname.com
  512. IP addresses to listen on: blank
  513. Destinations: mydomainname.com
  514. Domains to relay mail: blank
  515. Smarthost Relay: 192.168.1.0/60 (the range of addresses on your LAN)
  516. Dial on demand = no
  517. Maildir format in home directory
  518. Split configuration = no
  519. Root and postmaster: root email
  520. #+END_SRC
  521. To test the installation:
  522. #+BEGIN_SRC: bash
  523. telnet 192.168.1.60 25
  524. ehlo xxx
  525. quit
  526. #+END_SRC
  527. #+BEGIN_SRC: bash
  528. emacs /etc/default/saslauthd
  529. #+END_SRC
  530. set START=yes then save and exit.
  531. #+BEGIN_SRC: bash
  532. /etc/init.d/saslauthd start
  533. emacs exim-gencert
  534. #+END_SRC
  535. #+BEGIN_SRC: bash
  536. #!/bin/sh -e
  537. if [ -n "$EX4DEBUG" ]; then
  538. echo "now debugging $0 $@"
  539. set -x
  540. fi
  541. DIR=/etc/exim4
  542. CERT=$DIR/exim.crt
  543. KEY=$DIR/exim.key
  544. # This exim binary was built with GnuTLS which does not support dhparams
  545. # from a file. See /usr/share/doc/exim4-base/README.Debian.gz
  546. #DH=$DIR/exim.dhparam
  547. if ! which openssl > /dev/null ;then
  548. echo "$0: openssl is not installed, exiting" 1>&2
  549. exit 1
  550. fi
  551. # valid for ten years
  552. DAYS=3650
  553. if [ "$1" != "--force" ] && [ -f $CERT ] && [ -f $KEY ]; then
  554. echo "[*] $CERT and $KEY exists!"
  555. echo " Use \"$0 --force\" to force generation!"
  556. exit 0
  557. fi
  558. if [ "$1" = "--force" ]; then
  559. shift
  560. fi
  561. #SSLEAY=/tmp/exim.ssleay.$$.cnf
  562. SSLEAY="$(tempfile -m600 -pexi)"
  563. cat > $SSLEAY <<EOM
  564. RANDFILE = $HOME/.rnd
  565. [ req ]
  566. default_bits = 4096
  567. default_keyfile = exim.key
  568. distinguished_name = req_distinguished_name
  569. [ req_distinguished_name ]
  570. countryName = Country Code (2 letters)
  571. countryName_default = GB
  572. countryName_min = 2
  573. countryName_max = 2
  574. stateOrProvinceName = State or Province Name (full name)
  575. localityName = Locality Name (eg, city)
  576. organizationName = Organization Name (eg, company; recommended)
  577. organizationName_max = 64
  578. organizationalUnitName = Organizational Unit Name (eg, section)
  579. organizationalUnitName_max = 64
  580. commonName = Server name (eg. ssl.domain.tld; required!!!)
  581. commonName_max = 64
  582. emailAddress = Email Address
  583. emailAddress_max = 40
  584. EOM
  585. echo "[*] Creating a self signed SSL certificate for Exim!"
  586. echo " This may be sufficient to establish encrypted connections but for"
  587. echo " secure identification you need to buy a real certificate!"
  588. echo " "
  589. echo " Please enter the hostname of your MTA at the Common Name (CN) prompt!"
  590. echo " "
  591. openssl req -config $SSLEAY -x509 -sha256 -newkey rsa:4096 -keyout $KEY -out $CERT -days $DAYS -nodes
  592. #see README.Debian.gz*# openssl dhparam -check -text -5 512 -out $DH
  593. rm -f $SSLEAY
  594. chown root:Debian-exim $KEY $CERT $DH
  595. chmod 640 $KEY $CERT $DH
  596. echo "[*] Done generating self signed certificates for exim!"
  597. echo " Refer to the documentation and example configuration files"
  598. echo " over at /usr/share/doc/exim4-base/ for an idea on how to enable TLS"
  599. echo " support in your mail transfer agent."
  600. #+END_SRC
  601. Save and exit
  602. #+BEGIN_SRC: bash
  603. chmod +x exim-gencert
  604. ./exim-gencert
  605. #+END_SRC
  606. 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.
  607. #+BEGIN_SRC: bash
  608. emacs /etc/exim4/exim4.conf.template
  609. #+END_SRC
  610. Append the following:
  611. #+BEGIN_SRC: bash
  612. login_saslauthd_server:
  613. driver = plaintext
  614. public_name = LOGIN
  615. server_prompts = "Username:: : Password::"
  616. # don't send system passwords over unencrypted connections
  617. server_condition = ${if saslauthd{{$auth1}{$auth2}}{1}{0}}
  618. server_set_id = $auth1
  619. .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
  620. server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
  621. .endif
  622. #+END_SRC
  623. Search for the line *.ifdef MAIN_HARDCODE_PRIMARY_HOSTNAME* and above it insert the line:
  624. #+BEGIN_SRC: bash
  625. MAIN_HARDCODE_PRIMARY_HOSTNAME = mydomainname.com
  626. #+END_SRC
  627. Save and exit.
  628. #+BEGIN_SRC: bash
  629. emacs /etc/exim4/exim4.conf.template
  630. #+END_SRC
  631. Add the line:
  632. #+BEGIN_SRC: bash
  633. MAIN_TLS_ENABLE = true
  634. #+END_SRC
  635. Save and exit.
  636. #+BEGIN_SRC: bash
  637. emacs /etc/default/exim4
  638. change SMTPLISTENEROPTIONS to:
  639. SMTPLISTENEROPTIONS='-oX 465:25 -oP /var/run/exim4/exim.pid'
  640. #+END_SRC
  641. save and exit
  642. #+BEGIN_SRC: bash
  643. emacs /etc/exim4/exim4.conf.template
  644. under the section "main/03_exim4-config_tlsoptions"
  645. Add the following:
  646. tls_on_connect_ports=465
  647. #+END_SRC
  648. save and exit
  649. #+BEGIN_SRC: bash
  650. adduser myusername sasl
  651. addgroup Debian-exim sasl
  652. /etc/init.d/exim4 restart
  653. mkdir -m 700 /etc/skel/Maildir
  654. mkdir -m 700 /etc/skel/Maildir/Sent
  655. mkdir -m 700 /etc/skel/Maildir/Sent/tmp
  656. mkdir -m 700 /etc/skel/Maildir/Sent/cur
  657. mkdir -m 700 /etc/skel/Maildir/Sent/new
  658. mkdir -m 700 /etc/skel/Maildir/.learn-spam
  659. mkdir -m 700 /etc/skel/Maildir/.learn-spam/cur
  660. mkdir -m 700 /etc/skel/Maildir/.learn-spam/new
  661. mkdir -m 700 /etc/skel/Maildir/.learn-spam/tmp
  662. mkdir -m 700 /etc/skel/Maildir/.learn-ham
  663. mkdir -m 700 /etc/skel/Maildir/.learn-ham/cur
  664. mkdir -m 700 /etc/skel/Maildir/.learn-ham/new
  665. mkdir -m 700 /etc/skel/Maildir/.learn-ham/tmp
  666. ln -s /etc/skel/Maildir/.learn-spam /etc/skel/Maildir/spam
  667. ln -s /etc/skel/Maildir/.learn-ham /etc/skel/Maildir/ham
  668. #+END_SRC
  669. If you're starting from scratch and don't already have a /Maildir/ directory in your home directory, then create one as follows:
  670. #+BEGIN_SRC: bash
  671. export MYUSERNAME=myusername
  672. mkdir -m 700 /home/$MYUSERNAME/Maildir
  673. mkdir -m 700 /home/$MYUSERNAME/Maildir/cur
  674. mkdir -m 700 /home/$MYUSERNAME/Maildir/tmp
  675. mkdir -m 700 /home/$MYUSERNAME/Maildir/new
  676. mkdir -m 700 /home/$MYUSERNAME/Maildir/Sent
  677. mkdir -m 700 /home/$MYUSERNAME/Maildir/Sent/cur
  678. mkdir -m 700 /home/$MYUSERNAME/Maildir/Sent/tmp
  679. mkdir -m 700 /home/$MYUSERNAME/Maildir/Sent/new
  680. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-spam
  681. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-spam/cur
  682. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-spam/new
  683. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-spam/tmp
  684. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-ham
  685. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-ham/cur
  686. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-ham/new
  687. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-ham/tmp
  688. ln -s /home/$MYUSERNAME/Maildir/.learn-spam /home/$MYUSERNAME/Maildir/spam
  689. ln -s /home/$MYUSERNAME/Maildir/.learn-ham /home/$MYUSERNAME/Maildir/ham
  690. chown -R $MYUSERNAME:$MYUSERNAME /home/$MYUSERNAME/Maildir
  691. #+END_SRC
  692. ** Spam filtering
  693. #+BEGIN_SRC: bash
  694. apt-get install spamassassin exim4-daemon-heavy
  695. emacs /etc/default/spamassassin
  696. #+END_SRC
  697. Set ENABLED=1 then save and exit.
  698. #+BEGIN_SRC: bash
  699. emacs /etc/exim4/exim4.conf.template
  700. #+END_SRC
  701. uncomment or change according to your configuration
  702. #+BEGIN_SRC: bash
  703. # For spam scanning, there is a similar option that defines the interface to
  704. # SpamAssassin. You do not need to set this if you are using the default, which
  705. # is shown in this commented example. As for virus scanning, you must also
  706. # modify the acl_check_data access control list to enable spam scanning.
  707. spamd_address = 127.0.0.1 783
  708. #+END_SRC
  709. add spam header in the /acl_check_data/ section:
  710. #+BEGIN_SRC: bash
  711. ### acl/40_exim4-config_check_data
  712. #################################
  713. # This ACL is used after the contents of a message have been received. This
  714. # is the ACL in which you can test a message's headers or body, and in
  715. # particular, this is where you can invoke external virus or spam scanners.
  716. acl_check_data:
  717. ...
  718. ...
  719. ...
  720. # See the exim docs and the exim wiki for more suitable examples.
  721. #
  722. # warn
  723. # spam = Debian-exim:true
  724. # add_header = X-Spam_score: $spam_score\n\
  725. # X-Spam_score_int: $spam_score_int\n\
  726. # X-Spam_bar: $spam_bar\n\
  727. # X-Spam_report: $spam_report
  728. # put headers in all messages (no matter if spam or not)
  729. warn spam = nobody:true
  730. add_header = X-Spam-Score: $spam_score ($spam_bar)
  731. add_header = X-Spam-Report: $spam_report
  732. # add second subject line with *SPAM* marker when message
  733. # is over threshold
  734. warn spam = nobody
  735. add_header = Subject: ***SPAM (score:$spam_score)*** $h_Subject:
  736. #+END_SRC
  737. Save and exit.
  738. Then restart
  739. #+BEGIN_SRC: bash
  740. exit
  741. emacs ~/.procmailrc
  742. #+END_SRC
  743. The text should look like the following.
  744. #+BEGIN_SRC: sh
  745. MAILDIR=$HOME/Maildir
  746. DEFAULT=$MAILDIR/
  747. LOGFILE=$HOME/log/procmail.log
  748. LOGABSTRACT=all
  749. # get spamassassin to check emails
  750. :0fw: .spamassassin.lock
  751. * < 256000
  752. | spamc
  753. # strong spam are discarded
  754. :0
  755. * ^X-Spam-Level: \*\*\*\*\*\*
  756. /dev/null
  757. # weak spam are kept just in case - clear this out every now and then
  758. :0
  759. * ^X-Spam-Level: \*\*\*\*\*
  760. .0-spam/
  761. # otherwise, marginal spam goes here for revision
  762. :0
  763. * ^X-Spam-Level: \*\*
  764. .spam/
  765. #+END_SRC
  766. Save and exit.
  767. #+BEGIN_SRC: bash
  768. su
  769. emacs /usr/bin/filterspam
  770. #+END_SRC
  771. Add the following contents:
  772. #+BEGIN_SRC: bash
  773. #!/bin/bash
  774. USERNAME=$1
  775. MAILDIR=/home/$USERNAME/Maildir/.learn-spam
  776. if [ ! -d "$MAILDIR" ]; then
  777. exit
  778. fi
  779. for f in `ls $MAILDIR/cur`
  780. do
  781. spamc -L spam < "$MAILDIR/cur/$f" > /dev/null
  782. rm "$MAILDIR/cur/$f"
  783. done
  784. for f in `ls $MAILDIR/new`
  785. do
  786. spamc -L spam < "$MAILDIR/new/$f" > /dev/null
  787. rm "$MAILDIR/new/$f"
  788. done
  789. #+END_SRC
  790. Save and exit.
  791. #+BEGIN_SRC: bash
  792. emacs /usr/bin/filterham
  793. #+END_SRC
  794. Add the following contents:
  795. #+BEGIN_SRC: bash
  796. #!/bin/bash
  797. USERNAME=$1
  798. MAILDIR=/home/$USERNAME/Maildir/.learn-ham
  799. if [ ! -d "$MAILDIR" ]; then
  800. exit
  801. fi
  802. for f in `ls $MAILDIR/cur`
  803. do
  804. spamc -L ham < "$MAILDIR/cur/$f" > /dev/null
  805. rm "$MAILDIR/cur/$f"
  806. done
  807. for f in `ls $MAILDIR/new`
  808. do
  809. spamc -L ham < "$MAILDIR/new/$f" > /dev/null
  810. rm "$MAILDIR/new/$f"
  811. done
  812. #+END_SRC
  813. Save and exit.
  814. #+BEGIN_SRC: bash
  815. emacs /etc/crontab
  816. #+END_SRC
  817. Append the following, replacing *myusername* with your username.
  818. #+BEGIN_SRC: bash
  819. */3 * * * * root /usr/bin/timeout 120 /usr/bin/filterspam myusername
  820. */3 * * * * root /usr/bin/timeout 120 /usr/bin/filterham myusername
  821. #+END_SRC
  822. Save and exit.
  823. #+BEGIN_SRC: bash
  824. chmod 655 /usr/bin/filterspam /usr/bin/filterham
  825. service spamassassin restart
  826. service exim4 restart
  827. service cron restart
  828. #+END_SRC
  829. ** Install Dovecot
  830. #+BEGIN_VERSE
  831. /I dreamt last night that I was living in a surveillance state. I woke up and… I’m still in a surveillance state./
  832. -- Conrad Kramer
  833. #+END_VERSE
  834. Install the required packages.
  835. #+BEGIN_SRC: bash
  836. aptitude -y install dovecot-common dovecot-pop3d dovecot-imapd
  837. #+END_SRC
  838. Edit the configuration file.
  839. #+BEGIN_SRC: bash
  840. emacs /etc/dovecot/dovecot.conf
  841. #+END_SRC
  842. Line 26: change:
  843. #+BEGIN_SRC: bash
  844. listen = *
  845. #+END_SRC
  846. Save and exit.
  847. #+BEGIN_SRC: bash
  848. emacs /etc/dovecot/conf.d/10-auth.conf
  849. #+END_SRC
  850. Line 9: uncomment and change (allow plain text auth)
  851. #+BEGIN_SRC: bash
  852. disable_plaintext_auth = no
  853. #+END_SRC
  854. Line 99: add:
  855. #+BEGIN_SRC: bash
  856. auth_mechanisms = plain login
  857. #+END_SRC
  858. Save and exit.
  859. #+BEGIN_SRC: bash
  860. emacs /etc/dovecot/conf.d/10-mail.conf
  861. #+END_SRC
  862. Line 30: uncomment and add:
  863. #+BEGIN_SRC: bash
  864. mail_location = maildir:~/Maildir:LAYOUT=fs
  865. #+END_SRC
  866. Save and exit, then start the dovecot service.
  867. #+BEGIN_SRC: bash
  868. service dovecot restart
  869. #+END_SRC
  870. ** Create a GPG key
  871. #+BEGIN_VERSE
  872. /If privacy is outlawed, only outlaws will have privacy./
  873. -- Philip Zimmermann
  874. #+END_VERSE
  875. *** Initial installation
  876. Assuming that you are logged in as root, first ensure that GPG is installed and then exit to your user account.
  877. #+BEGIN_SRC: bash
  878. apt-get install gnupg
  879. exit
  880. #+END_SRC
  881. Now we will add some settings:
  882. #+BEGIN_SRC: bash
  883. mkdir ~/.gnupg
  884. emacs ~/.gnupg/gpg.conf
  885. #+END_SRC
  886. The configuration should look like the following. Of particular importance are the default preferences at the end.
  887. #+BEGIN_SRC: bash
  888. # Options for GnuPG
  889. # Copyright 1998, 1999, 2000, 2001, 2002, 2003,
  890. # 2010 Free Software Foundation, Inc.
  891. #
  892. # This file is free software; as a special exception the author gives
  893. # unlimited permission to copy and/or distribute it, with or without
  894. # modifications, as long as this notice is preserved.
  895. #
  896. # This file is distributed in the hope that it will be useful, but
  897. # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
  898. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  899. #
  900. # Unless you specify which option file to use (with the command line
  901. # option "--options filename"), GnuPG uses the file ~/.gnupg/gpg.conf
  902. # by default.
  903. #
  904. # An options file can contain any long options which are available in
  905. # GnuPG. If the first non white space character of a line is a '#',
  906. # this line is ignored. Empty lines are also ignored.
  907. #
  908. # See the man page for a list of options.
  909. # Uncomment the following option to get rid of the copyright notice
  910. #no-greeting
  911. # If you have more than 1 secret key in your keyring, you may want to
  912. # uncomment the following option and set your preferred keyid.
  913. #default-key 621CC013
  914. # If you do not pass a recipient to gpg, it will ask for one. Using
  915. # this option you can encrypt to a default key. Key validation will
  916. # not be done in this case. The second form uses the default key as
  917. # default recipient.
  918. #default-recipient some-user-id
  919. #default-recipient-self
  920. # Use --encrypt-to to add the specified key as a recipient to all
  921. # messages. This is useful, for example, when sending mail through a
  922. # mail client that does not automatically encrypt mail to your key.
  923. # In the example, this option allows you to read your local copy of
  924. # encrypted mail that you've sent to others.
  925. #encrypt-to some-key-id
  926. # By default GnuPG creates version 4 signatures for data files as
  927. # specified by OpenPGP. Some earlier (PGP 6, PGP 7) versions of PGP
  928. # require the older version 3 signatures. Setting this option forces
  929. # GnuPG to create version 3 signatures.
  930. #force-v3-sigs
  931. # Because some mailers change lines starting with "From " to ">From "
  932. # it is good to handle such lines in a special way when creating
  933. # cleartext signatures; all other PGP versions do it this way too.
  934. #no-escape-from-lines
  935. # If you do not use the Latin-1 (ISO-8859-1) charset, you should tell
  936. # GnuPG which is the native character set. Please check the man page
  937. # for supported character sets. This character set is only used for
  938. # metadata and not for the actual message which does not undergo any
  939. # translation. Note that future version of GnuPG will change to UTF-8
  940. # as default character set. In most cases this option is not required
  941. # as GnuPG is able to figure out the correct charset at runtime.
  942. #charset utf-8
  943. # Group names may be defined like this:
  944. # group mynames = paige 0x12345678 joe patti
  945. #
  946. # Any time "mynames" is a recipient (-r or --recipient), it will be
  947. # expanded to the names "paige", "joe", and "patti", and the key ID
  948. # "0x12345678". Note there is only one level of expansion - you
  949. # cannot make an group that points to another group. Note also that
  950. # if there are spaces in the recipient name, this will appear as two
  951. # recipients. In these cases it is better to use the key ID.
  952. #group mynames = paige 0x12345678 joe patti
  953. # Lock the file only once for the lifetime of a process. If you do
  954. # not define this, the lock will be obtained and released every time
  955. # it is needed, which is usually preferable.
  956. #lock-once
  957. # GnuPG can send and receive keys to and from a keyserver. These
  958. # servers can be HKP, email, or LDAP (if GnuPG is built with LDAP
  959. # support).
  960. #
  961. # Example HKP keyserver:
  962. # hkp://keys.gnupg.net
  963. # hkp://subkeys.pgp.net
  964. #
  965. # Example email keyserver:
  966. # mailto:pgp-public-keys@keys.pgp.net
  967. #
  968. # Example LDAP keyservers:
  969. # ldap://keyserver.pgp.com
  970. #
  971. # Regular URL syntax applies, and you can set an alternate port
  972. # through the usual method:
  973. # hkp://keyserver.example.net:22742
  974. #
  975. # Most users just set the name and type of their preferred keyserver.
  976. # Note that most servers (with the notable exception of
  977. # ldap://keyserver.pgp.com) synchronize changes with each other. Note
  978. # also that a single server name may actually point to multiple
  979. # servers via DNS round-robin. hkp://keys.gnupg.net is an example of
  980. # such a "server", which spreads the load over a number of physical
  981. # servers. To see the IP address of the server actually used, you may use
  982. # the "--keyserver-options debug".
  983. keyserver hkp://keys.gnupg.net
  984. #keyserver mailto:pgp-public-keys@keys.nl.pgp.net
  985. #keyserver ldap://keyserver.pgp.com
  986. # Common options for keyserver functions:
  987. #
  988. # include-disabled : when searching, include keys marked as "disabled"
  989. # on the keyserver (not all keyservers support this).
  990. #
  991. # no-include-revoked : when searching, do not include keys marked as
  992. # "revoked" on the keyserver.
  993. #
  994. # verbose : show more information as the keys are fetched.
  995. # Can be used more than once to increase the amount
  996. # of information shown.
  997. #
  998. # use-temp-files : use temporary files instead of a pipe to talk to the
  999. # keyserver. Some platforms (Win32 for one) always
  1000. # have this on.
  1001. #
  1002. # keep-temp-files : do not delete temporary files after using them
  1003. # (really only useful for debugging)
  1004. #
  1005. # http-proxy="proxy" : set the proxy to use for HTTP and HKP keyservers.
  1006. # This overrides the "http_proxy" environment variable,
  1007. # if any.
  1008. #
  1009. # auto-key-retrieve : automatically fetch keys as needed from the keyserver
  1010. # when verifying signatures or when importing keys that
  1011. # have been revoked by a revocation key that is not
  1012. # present on the keyring.
  1013. #
  1014. # no-include-attributes : do not include attribute IDs (aka "photo IDs")
  1015. # when sending keys to the keyserver.
  1016. keyserver-options auto-key-retrieve
  1017. # Display photo user IDs in key listings
  1018. # list-options show-photos
  1019. # Display photo user IDs when a signature from a key with a photo is
  1020. # verified
  1021. # verify-options show-photos
  1022. # Use this program to display photo user IDs
  1023. #
  1024. # %i is expanded to a temporary file that contains the photo.
  1025. # %I is the same as %i, but the file isn't deleted afterwards by GnuPG.
  1026. # %k is expanded to the key ID of the key.
  1027. # %K is expanded to the long OpenPGP key ID of the key.
  1028. # %t is expanded to the extension of the image (e.g. "jpg").
  1029. # %T is expanded to the MIME type of the image (e.g. "image/jpeg").
  1030. # %f is expanded to the fingerprint of the key.
  1031. # %% is %, of course.
  1032. #
  1033. # If %i or %I are not present, then the photo is supplied to the
  1034. # viewer on standard input. If your platform supports it, standard
  1035. # input is the best way to do this as it avoids the time and effort in
  1036. # generating and then cleaning up a secure temp file.
  1037. #
  1038. # If no photo-viewer is provided, GnuPG will look for xloadimage, eog,
  1039. # or display (ImageMagick). On Mac OS X and Windows, the default is
  1040. # to use your regular JPEG image viewer.
  1041. #
  1042. # Some other viewers:
  1043. # photo-viewer "qiv %i"
  1044. # photo-viewer "ee %i"
  1045. #
  1046. # This one saves a copy of the photo ID in your home directory:
  1047. # photo-viewer "cat > ~/photoid-for-key-%k.%t"
  1048. #
  1049. # Use your MIME handler to view photos:
  1050. # photo-viewer "metamail -q -d -b -c %T -s 'KeyID 0x%k' -f GnuPG"
  1051. # Passphrase agent
  1052. #
  1053. # We support the old experimental passphrase agent protocol as well as
  1054. # the new Assuan based one (currently available in the "newpg" package
  1055. # at ftp.gnupg.org/gcrypt/alpha/aegypten/). To make use of the agent,
  1056. # you have to run an agent as daemon and use the option
  1057. #
  1058. # use-agent
  1059. #
  1060. # which tries to use the agent but will fallback to the regular mode
  1061. # if there is a problem connecting to the agent. The normal way to
  1062. # locate the agent is by looking at the environment variable
  1063. # GPG_AGENT_INFO which should have been set during gpg-agent startup.
  1064. # In certain situations the use of this variable is not possible, thus
  1065. # the option
  1066. #
  1067. # --gpg-agent-info=<path>:<pid>:1
  1068. #
  1069. # may be used to override it.
  1070. # Automatic key location
  1071. #
  1072. # GnuPG can automatically locate and retrieve keys as needed using the
  1073. # auto-key-locate option. This happens when encrypting to an email
  1074. # address (in the "user@example.com" form), and there are no
  1075. # user@example.com keys on the local keyring. This option takes the
  1076. # following arguments, in the order they are to be tried:
  1077. #
  1078. # cert = locate a key using DNS CERT, as specified in RFC-4398.
  1079. # GnuPG can handle both the PGP (key) and IPGP (URL + fingerprint)
  1080. # CERT methods.
  1081. #
  1082. # pka = locate a key using DNS PKA.
  1083. #
  1084. # ldap = locate a key using the PGP Universal method of checking
  1085. # "ldap://keys.(thedomain)". For example, encrypting to
  1086. # user@example.com will check ldap://keys.example.com.
  1087. #
  1088. # keyserver = locate a key using whatever keyserver is defined using
  1089. # the keyserver option.
  1090. #
  1091. # You may also list arbitrary keyservers here by URL.
  1092. #
  1093. # Try CERT, then PKA, then LDAP, then hkp://subkeys.net:
  1094. #auto-key-locate cert pka ldap hkp://subkeys.pgp.net
  1095. # default preferences
  1096. personal-digest-preferences SHA256
  1097. cert-digest-algo SHA256
  1098. default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
  1099. #+END_SRC
  1100. Save and exit.
  1101. *** If you have an existing key
  1102. #+BEGIN_SRC: bash
  1103. gpg --import ~/public_key.txt
  1104. gpg --allow-secret-key-import --import ~/private_key.txt
  1105. shred -zu ~/private_key.txt
  1106. #+END_SRC
  1107. Now check the digest preferences, replacing /keyID/ with your GPG key ID. This applies especially if you have a key which was generated some time ago.
  1108. #+BEGIN_SRC: bash
  1109. export MYGPGKEYID=keyID
  1110. gpg --edit-key $MYGPGKEYID
  1111. setpref SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
  1112. save
  1113. gpg --send-keys $MYGPGKEYID
  1114. #+END_SRC
  1115. *** To create a new key
  1116. Generate a key with the following command:
  1117. #+BEGIN_SRC: bash
  1118. gpg --gen-key
  1119. #+END_SRC
  1120. You can find your GPG key ID by entering:
  1121. #+BEGIN_SRC: bash
  1122. gpg --list-keys
  1123. #+END_SRC
  1124. The key ID is the second part of the string of numbers and letters. So for example in:
  1125. #+BEGIN_SRC: bash
  1126. pub 4096R/EA982E38 2012-05-20
  1127. #+END_SRC
  1128. the key ID is EA982E38. Now send your public key to a server so that others can find it.
  1129. #+BEGIN_SRC: bash
  1130. gpg --send-keys $MYGPGKEYID
  1131. #+END_SRC
  1132. *** root settings
  1133. If you later create an encrypted mailing list then the root user will also need to have good GPG settings so that it can generate key pairs for the list. The easiest way to ensure this is to do the following, replacing /myusername/ with your username:
  1134. #+BEGIN_SRC: bash
  1135. su
  1136. cp -r /home/myusername/.gnupg ~/
  1137. chown -R root:root ~/.gnupg
  1138. #+END_SRC
  1139. ** Create Email folders and rules
  1140. #+BEGIN_VERSE
  1141. /Yes, the NSA set fire to the Internet but it’s the business models of Google, Facebook, etc, that provide the firewood. Trusting the companies supplying the firewood to be your fire fighters is naïve at best./
  1142. -- Aral Balkan
  1143. #+END_VERSE
  1144. *** Rules for mailing lists
  1145. A common situation with email is that you may be subscribed to various mailing lists and want incoming email from those to be automatically grouped into a separate folder for each list.
  1146. We can make a script to make adding mailing list rules easy:
  1147. #+BEGIN_SRC: bash
  1148. emacs /usr/bin/mailinglistrule
  1149. #+END_SRC
  1150. Add the following:
  1151. #+BEGIN_SRC: bash
  1152. #!/bin/bash
  1153. MYUSERNAME=$1
  1154. MAILINGLIST=$2
  1155. SUBJECTTAG=$3
  1156. MUTTRC=/home/$MYUSERNAME/.muttrc
  1157. PM=/home/$MYUSERNAME/.procmailrc
  1158. LISTDIR=/home/$MYUSERNAME/Maildir/$MAILINGLIST
  1159. if [ ! -d "$LISTDIR" ]; then
  1160. mkdir -m 700 $LISTDIR
  1161. mkdir -m 700 $LISTDIR/tmp
  1162. mkdir -m 700 $LISTDIR/new
  1163. mkdir -m 700 $LISTDIR/cur
  1164. fi
  1165. chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR
  1166. echo "" >> $PM
  1167. echo ":0" >> $PM
  1168. echo " * ^Subject:.*()\[$SUBJECTTAG\]" >> $PM
  1169. echo "$LISTDIR/new" >> $PM
  1170. chown $MYUSERNAME:$MYUSERNAME $PM
  1171. if [ ! -f "$MUTTRC" ]; then
  1172. cp /etc/Muttrc $MUTTRC
  1173. chown $MYUSERNAME:$MYUSERNAME $MUTTRC
  1174. fi
  1175. PROCMAILLOG=/home/$MYUSERNAME/log
  1176. if [ ! -d $PROCMAILLOG ]; then
  1177. mkdir $PROCMAILLOG
  1178. chown -R $MYUSERNAME:$MYUSERNAME $PROCMAILLOG
  1179. fi
  1180. #+END_SRC
  1181. Save and exit, then make the script executable.
  1182. #+BEGIN_SRC: bash
  1183. chmod +x /usr/bin/mailinglistrule
  1184. #+END_SRC
  1185. Now we can add a new mailing list rule with the following, where /myusername/ is your username, /mailinglistname/ is the name of the mailing list (with no spaces) and /subjecttag/ is the tag which usually appears within square brackets in the subject line of emails from the list.
  1186. #+BEGIN_SRC: bash
  1187. mailinglistrule [myusername] [mailinglistname] [subjecttag]
  1188. #+END_SRC
  1189. Repeat this command for as many mailing lists as you need. Then edit your local Mutt configuration.
  1190. #+BEGIN_SRC: bash
  1191. emacs /home/myusername/.muttrc
  1192. #+END_SRC
  1193. Search for the *mailboxes* variable and add entries for the mailing lists you just created. For example:
  1194. #+BEGIN_SRC: bash
  1195. mailboxes = =Sent =mailinglistname
  1196. #+END_SRC
  1197. Then save and exit.
  1198. *** Rules for specific email addresses
  1199. You can also make a script which will allow you to move mail from specific email addresses to a folder.
  1200. #+BEGIN_SRC: bash
  1201. emacs /usr/bin/emailrule
  1202. #+END_SRC
  1203. Add the following:
  1204. #+BEGIN_SRC: bash
  1205. #!/bin/bash
  1206. MYUSERNAME=$1
  1207. EMAILADDRESS=$2
  1208. MAILINGLIST=$3
  1209. MUTTRC=/home/$MYUSERNAME/.muttrc
  1210. PM=/home/$MYUSERNAME/.procmailrc
  1211. LISTDIR=/home/$MYUSERNAME/Maildir/$MAILINGLIST
  1212. if [ ! -d "$LISTDIR" ]; then
  1213. mkdir -m 700 $LISTDIR
  1214. mkdir -m 700 $LISTDIR/tmp
  1215. mkdir -m 700 $LISTDIR/new
  1216. mkdir -m 700 $LISTDIR/cur
  1217. fi
  1218. chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR
  1219. echo "" >> $PM
  1220. echo ":0" >> $PM
  1221. echo " * ^From: $EMAILADDRESS" >> $PM
  1222. echo "$LISTDIR/new" >> $PM
  1223. chown $MYUSERNAME:$MYUSERNAME $PM
  1224. if [ ! -f "$MUTTRC" ]; then
  1225. cp /etc/Muttrc $MUTTRC
  1226. chown $MYUSERNAME:$MYUSERNAME $MUTTRC
  1227. fi
  1228. PROCMAILLOG=/home/$MYUSERNAME/log
  1229. if [ ! -d $PROCMAILLOG ]; then
  1230. mkdir $PROCMAILLOG
  1231. chown -R $MYUSERNAME:$MYUSERNAME $PROCMAILLOG
  1232. fi
  1233. #+END_SRC
  1234. Save and exit, then make the script executable.
  1235. #+BEGIN_SRC: bash
  1236. chmod +x /usr/bin/emailrule
  1237. #+END_SRC
  1238. Then to add a particular email address to a folder run the command:
  1239. #+BEGIN_SRC: bash
  1240. emailrule [myusername] [emailaddress] [foldername]
  1241. #+END_SRC
  1242. If you want any mail from the given email address to be deleted then set the /foldername/ to /Trash/.
  1243. To ensure that the folder appears within Mutt.
  1244. #+BEGIN_SRC: bash
  1245. emacs /home/myusername/.muttrc
  1246. #+END_SRC
  1247. Search for the *mailboxes* variable and add entries for the mailing lists you just created. For example:
  1248. #+BEGIN_SRC: bash
  1249. mailboxes = =Sent =foldername
  1250. #+END_SRC
  1251. Then save and exit.
  1252. ** Setting up a web site
  1253. #+BEGIN_VERSE
  1254. /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./
  1255. -- Tim Berners-Lee
  1256. #+END_VERSE
  1257. Edit the apache configuration so that it doesn't run out of memory if there are a lot of connections.
  1258. #+BEGIN_SRC: bash
  1259. su
  1260. emacs /etc/apache2/apache2.conf
  1261. #+END_SRC
  1262. Search for MaxClients and replace the value with 6. As an example the settings should look something like this:
  1263. #+BEGIN_SRC: bash
  1264. <IfModule mpm_prefork_module>
  1265. StartServers 3
  1266. MinSpareServers 3
  1267. MaxSpareServers 5
  1268. MaxClients 6
  1269. MaxRequestsPerChild 0
  1270. </IfModule>
  1271. <IfModule mpm_worker_module>
  1272. StartServers 2
  1273. MinSpareThreads 25
  1274. MaxSpareThreads 75
  1275. ThreadLimit 64
  1276. ThreadsPerChild 25
  1277. MaxClients 6
  1278. MaxRequestsPerChild 0
  1279. </IfModule>
  1280. <IfModule mpm_event_module>
  1281. StartServers 2
  1282. MinSpareThreads 25
  1283. MaxSpareThreads 75
  1284. ThreadLimit 64
  1285. ThreadsPerChild 25
  1286. MaxClients 6
  1287. MaxRequestsPerChild 0
  1288. </IfModule>
  1289. #+END_SRC
  1290. Then save and exit In the examples below replace /mydomainname.com/ with your own domain name.
  1291. #+BEGIN_SRC: bash
  1292. export HOSTNAME=mydomainname.com
  1293. mkdir /var/www/$HOSTNAME
  1294. mkdir /var/www/$HOSTNAME/htdocs
  1295. emacs /etc/apache2/sites-available/$HOSTNAME
  1296. #+END_SRC
  1297. The Apache configuration for the site should look something like the following. Replace /mydonainname.com/ with the site domain name.
  1298. #+BEGIN_SRC: bash
  1299. <VirtualHost *:80>
  1300. ServerAdmin myusername@mydomainname.com
  1301. ServerName mydomainname.com
  1302. DocumentRoot /var/www/mydomainname.com/htdocs
  1303. <Directory />
  1304. Options FollowSymLinks
  1305. AllowOverride All
  1306. </Directory>
  1307. <Directory /var/www/mydomainname.com/htdocs/>
  1308. Options All
  1309. AllowOverride All
  1310. Order allow,deny
  1311. allow from all
  1312. </Directory>
  1313. # Don't serve .php~ or .php# files created by emacs
  1314. <Files ~ "(^#.*#|~|\.sw[op])$">
  1315. Order allow,deny
  1316. Deny from all
  1317. </Files>
  1318. <IfModule headers_module>
  1319. Header set X-Content-Type-Options nosniff
  1320. Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate, private"
  1321. Header set Pragma no-cache
  1322. </IfModule>
  1323. <Files .htaccess>
  1324. deny from all
  1325. </Files>
  1326. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  1327. <Directory "/usr/lib/cgi-bin">
  1328. AllowOverride All
  1329. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  1330. Order allow,deny
  1331. Allow from all
  1332. </Directory>
  1333. ErrorLog ${APACHE_LOG_DIR}/error.log
  1334. # Possible values include: debug, info, notice, warn, error, crit,
  1335. # alert, emerg.
  1336. LogLevel error
  1337. CustomLog ${APACHE_LOG_DIR}/access.log combined
  1338. </VirtualHost>
  1339. <IfModule mod_ssl.c>
  1340. <VirtualHost *:443>
  1341. ServerAdmin myusername@mydomainname.com
  1342. ServerName mydomainname.com
  1343. DocumentRoot /var/www/mydomainname.com/htdocs
  1344. <Directory />
  1345. Options FollowSymLinks
  1346. AllowOverride All
  1347. </Directory>
  1348. <Directory /var/www/mydomainname.com/htdocs/>
  1349. Options All
  1350. AllowOverride All
  1351. Order allow,deny
  1352. allow from all
  1353. </Directory>
  1354. # Don't serve .php~ or .php# files created by emacs
  1355. <Files ~ "(^#.*#|~|\.sw[op])$">
  1356. Order allow,deny
  1357. Deny from all
  1358. </Files>
  1359. <IfModule headers_module>
  1360. Header set X-Content-Type-Options nosniff
  1361. Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate, private"
  1362. Header set Pragma no-cache
  1363. </IfModule>
  1364. <Files .htaccess>
  1365. deny from all
  1366. </Files>
  1367. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  1368. <Directory "/usr/lib/cgi-bin">
  1369. AllowOverride All
  1370. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  1371. Order allow,deny
  1372. Allow from all
  1373. </Directory>
  1374. ErrorLog ${APACHE_LOG_DIR}/error.log
  1375. # Possible values include: debug, info, notice, warn, error, crit,
  1376. # alert, emerg.
  1377. LogLevel error
  1378. CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
  1379. # SSL Engine Switch:
  1380. # Enable/Disable SSL for this virtual host.
  1381. SSLEngine on
  1382. # A self-signed certificate
  1383. SSLCertificateFile /etc/ssl/certs/mydomainname.com.crt
  1384. SSLCertificateKeyFile /etc/ssl/private/mydomainname.com.key
  1385. # Options based on bettercrypto.org
  1386. SSLProtocol All -SSLv2 -SSLv3
  1387. SSLHonorCipherOrder On
  1388. SSLCompression off
  1389. 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
  1390. # Add six earth month HSTS header for all users ...
  1391. Header add Strict-Transport-Security "max-age=15768000"
  1392. # If you want to protect all subdomains , use the following header
  1393. # ALL subdomains HAVE TO support https if you use this !
  1394. # Strict-Transport-Security: max-age=15768000 ; includeSubDomains
  1395. # SSL Engine Options:
  1396. # Set various options for the SSL engine.
  1397. # o FakeBasicAuth:
  1398. # Translate the client X.509 into a Basic Authorisation. This means that
  1399. # the standard Auth/DBMAuth methods can be used for access control. The
  1400. # user name is the `one line' version of the client's X.509 certificate.
  1401. # Note that no password is obtained from the user. Every entry in the user
  1402. # file needs this password: `xxj31ZMTZzkVA'.
  1403. # o ExportCertData:
  1404. # This exports two additional environment variables: SSL_CLIENT_CERT and
  1405. # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
  1406. # server (always existing) and the client (only existing when client
  1407. # authentication is used). This can be used to import the certificates
  1408. # into CGI scripts.
  1409. # o StdEnvVars:
  1410. # This exports the standard SSL/TLS related `SSL_*' environment variables.
  1411. # Per default this exportation is switched off for performance reasons,
  1412. # because the extraction step is an expensive operation and is usually
  1413. # useless for serving static content. So one usually enables the
  1414. # exportation for CGI and SSI requests only.
  1415. # o StrictRequire:
  1416. # This denies access when "SSLRequireSSL" or "SSLRequire" applied even
  1417. # under a "Satisfy any" situation, i.e. when it applies access is denied
  1418. # and no other module can change it.
  1419. # o OptRenegotiate:
  1420. # This enables optimized SSL connection renegotiation handling when SSL
  1421. # directives are used in per-directory context.
  1422. #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
  1423. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  1424. SSLOptions +StdEnvVars
  1425. </FilesMatch>
  1426. <Directory /usr/lib/cgi-bin>
  1427. SSLOptions +StdEnvVars
  1428. </Directory>
  1429. # SSL Protocol Adjustments:
  1430. # The safe and default but still SSL/TLS standard compliant shutdown
  1431. # approach is that mod_ssl sends the close notify alert but doesn't wait for
  1432. # the close notify alert from client. When you need a different shutdown
  1433. # approach you can use one of the following variables:
  1434. # o ssl-unclean-shutdown:
  1435. # This forces an unclean shutdown when the connection is closed, i.e. no
  1436. # SSL close notify alert is send or allowed to received. This violates
  1437. # the SSL/TLS standard but is needed for some brain-dead browsers. Use
  1438. # this when you receive I/O errors because of the standard approach where
  1439. # mod_ssl sends the close notify alert.
  1440. # o ssl-accurate-shutdown:
  1441. # This forces an accurate shutdown when the connection is closed, i.e. a
  1442. # SSL close notify alert is send and mod_ssl waits for the close notify
  1443. # alert of the client. This is 100% SSL/TLS standard compliant, but in
  1444. # practice often causes hanging connections with brain-dead browsers. Use
  1445. # this only for browsers where you know that their SSL implementation
  1446. # works correctly.
  1447. # Notice: Most problems of broken clients are also related to the HTTP
  1448. # keep-alive facility, so you usually additionally want to disable
  1449. # keep-alive for those clients, too. Use variable "nokeepalive" for this.
  1450. # Similarly, one has to force some clients to use HTTP/1.0 to workaround
  1451. # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
  1452. # "force-response-1.0" for this.
  1453. BrowserMatch "MSIE [2-6]" \
  1454. nokeepalive ssl-unclean-shutdown \
  1455. downgrade-1.0 force-response-1.0
  1456. # MSIE 7 and newer should be able to use keepalive
  1457. BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  1458. </VirtualHost>
  1459. </IfModule>
  1460. #+END_SRC
  1461. Then to enable the site:
  1462. #+BEGIN_SRC: bash
  1463. a2ensite
  1464. a2dissite default
  1465. a2dissite default-ssl
  1466. a2enmod rewrite
  1467. a2enmod headers
  1468. #+END_SRC
  1469. Ensure that "NameVirtualHost *:443" is added to /etc/apache2/ports.conf. It should look something like the following:
  1470. #+BEGIN_SRC: bash
  1471. NameVirtualHost *:80
  1472. Listen 80
  1473. <IfModule mod_ssl.c>
  1474. NameVirtualHost *:443
  1475. Listen 443
  1476. </IfModule>
  1477. <IfModule mod_gnutls.c>
  1478. NameVirtualHost *:443
  1479. Listen 443
  1480. </IfModule>
  1481. #+END_SRC
  1482. Create a self-signed certificate. The passphrase isn't important and will be removed, so make it easy (such as "password").
  1483. #+BEGIN_SRC: bash
  1484. emacs makecert
  1485. #+END_SRC
  1486. Enter the following:
  1487. #+BEGIN_SRC: bash
  1488. #!/bin/bash
  1489. HOSTNAME=$1
  1490. openssl genrsa -des3 -out $HOSTNAME.key 1024
  1491. openssl req -new -x509 -nodes -sha1 -days 3650 -key $HOSTNAME.key -out $HOSTNAME.crt
  1492. openssl rsa -in $HOSTNAME.key -out $HOSTNAME.new.key
  1493. cp $HOSTNAME.new.key $HOSTNAME.key
  1494. rm $HOSTNAME.new.key
  1495. cp $HOSTNAME.key /etc/ssl/private
  1496. chmod 400 /etc/ssl/private/$HOSTNAME.key
  1497. cp $HOSTNAME.crt /etc/ssl/certs
  1498. shred -zu $HOSTNAME.key $HOSTNAME.crt
  1499. a2enmod ssl
  1500. service apache2 restart
  1501. #+END_SRC
  1502. Save and exit.
  1503. #+BEGIN_SRC: bash
  1504. chmod +x makecert
  1505. ./makecert mydomainname.com
  1506. #+END_SRC
  1507. 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.
  1508. 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.
  1509. ** Accessing your Email
  1510. #+BEGIN_VERSE
  1511. /The emails showed that Google...was among several other military/defense contractors vying for a piece of DAC’s $10.9-million surveillance contracting action./
  1512. -- Article on the "Google-Military-Surveillance Complex" by Yasha Levine
  1513. #+END_VERSE
  1514. *** Mutt email client
  1515. #+BEGIN_SRC: bash
  1516. apt-get install mutt-patched lynx abook
  1517. exit
  1518. mkdir ~/.mutt
  1519. echo "text/html; lynx -dump -width=78 -nolist %s | sed ‘s/^ //’; copiousoutput; needsterminal; nametemplate=%s.html" > ~/.mutt/mailcap
  1520. #+END_SRC
  1521. Save and exit.
  1522. #+BEGIN_SRC: bash
  1523. su
  1524. emacs /etc/Muttrc
  1525. #+END_SRC
  1526. Append the following:
  1527. #+BEGIN_SRC: bash
  1528. set mbox_type=Maildir
  1529. set folder="~/Maildir"
  1530. set mask="!^\\.[^.]"
  1531. set mbox="~/Maildir"
  1532. set record="+Sent"
  1533. set postponed="+Drafts"
  1534. set trash="+Trash"
  1535. set spoolfile="~/Maildir"
  1536. auto_view text/x-vcard text/html text/enriched
  1537. set editor="emacsclient %s"
  1538. set header_cache="+.cache"
  1539. macro index S "<tag-prefix><save-message>=.learn-spam<enter>" "move to learn-spam"
  1540. macro pager S "<save-message>=.learn-spam<enter>" "move to learn-spam"
  1541. macro index H "<tag-prefix><copy-message>=.learn-ham<enter>" "copy to learn-ham"
  1542. macro pager H "<copy-message>=.learn-ham<enter>" "copy to learn-ham"
  1543. # set up the sidebar
  1544. set sidebar_width=12
  1545. set sidebar_visible=yes
  1546. set sidebar_delim='|'
  1547. set sidebar_sort=yes
  1548. set rfc2047_parameters
  1549. # Show inbox and sent items
  1550. mailboxes = =Sent
  1551. # Alter these colours as needed for maximum bling
  1552. color sidebar_new yellow default
  1553. color normal white default
  1554. color hdrdefault brightcyan default
  1555. color signature green default
  1556. color attachment brightyellow default
  1557. color quoted green default
  1558. color quoted1 white default
  1559. color tilde blue default
  1560. # ctrl-n, ctrl-p to select next, prev folder
  1561. # ctrl-o to open selected folder
  1562. bind index \Cp sidebar-prev
  1563. bind index \Cn sidebar-next
  1564. bind index \Co sidebar-open
  1565. bind pager \Cp sidebar-prev
  1566. bind pager \Cn sidebar-next
  1567. bind pager \Co sidebar-open
  1568. # ctrl-b toggles sidebar visibility
  1569. macro index,pager \Cb '<enter-command>toggle sidebar_visible<enter><redraw-screen>' "toggle sidebar"
  1570. # esc-m Mark new messages as read
  1571. macro index <esc>m "T~N<enter>;WNT~O<enter>;WO\CT~T<enter>" "mark all messages read"
  1572. # Collapsing threads
  1573. macro index [ "<collapse-thread>" "collapse/uncollapse thread"
  1574. macro index ] "<collapse-all>" "collapse/uncollapse all threads"
  1575. # threads containing new messages
  1576. uncolor index "~(~N)"
  1577. color index brightblue default "~(~N)"
  1578. # new messages themselves
  1579. uncolor index "~N"
  1580. color index brightyellow default "~N"
  1581. # GPG/PGP integration
  1582. # this set the number of seconds to keep in memory the passphrase used to encrypt/sign
  1583. set pgp_timeout=60
  1584. # automatically sign and encrypt
  1585. set pgp_autosign # autosign all outgoing mails
  1586. set pgp_replyencrypt # autocrypt replies to crypted
  1587. set pgp_replysign # autosign replies to signed
  1588. #+END_SRC
  1589. Save and exit.
  1590. #+BEGIN_SRC: bash
  1591. emacs /etc/mail/spamassassin/local.cf
  1592. #+END_SRC
  1593. Uncomment *use_bayes*, *bayes_auto_learn*
  1594. Save and exit, then run:
  1595. #+BEGIN_SRC: bash
  1596. service spamassassin restart
  1597. #+END_SRC
  1598. Now to add an address book:
  1599. #+BEGIN_SRC: bash
  1600. emacs ~/.muttrc
  1601. #+END_SRC
  1602. Append the following:
  1603. #+BEGIN_SRC: bash
  1604. set alias_file=~/.mutt-alias
  1605. source ~/.mutt-alias
  1606. set query_command= "abook --mutt-query '%s'"
  1607. macro index,pager A "<pipe-message>abook --add-email-quiet<return>" "add the sender address to abook"
  1608. #+END_SRC
  1609. Then save and exit.
  1610. #+BEGIN_SRC: bash
  1611. touch ~/.mutt-alias
  1612. #+END_SRC
  1613. 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.
  1614. 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.
  1615. Some useful keys to know are:
  1616. | ESC / | Search for text within message contents |
  1617. | "/" | Search for text within headers |
  1618. | * | Move to the last message |
  1619. | TAB | Move to the next unread message |
  1620. | d | Delete a message |
  1621. | u | Undelete a mail which is pending deletion |
  1622. | $ | Delete all messages selected and check for new messages |
  1623. | a | Add to the address book |
  1624. | m | Send a new mail |
  1625. | ESC-m | Mark all messages as having been read |
  1626. | S | Mark a message as spam |
  1627. | H | Mark a message as ham |
  1628. | CTRL-b | Toggle side bar on/off |
  1629. | CTRL-n | Next mailbox (on side bar) |
  1630. | CTRL-p | Previous mailbox (on side bar) |
  1631. | CTRL-o | Open mailbox (on side bar) |
  1632. | ] | Expand or collapse all threads |
  1633. | [ | Expand of collapse the current thread |
  1634. | CTRL-k | Import a PGP/GPG public key |
  1635. *** K9 Android client
  1636. #+BEGIN_VERSE
  1637. /The surveillance state is robust. It is robust politically, legally, and technically./
  1638. -- Bruce Schneier
  1639. #+END_VERSE
  1640. **** Incoming server settings
  1641. * Select settings/account settings
  1642. * Select Fetching mail/incoming server
  1643. * Enter your username and password
  1644. * IMAP server should be your domain name
  1645. * Security: SSL/TLS (always)
  1646. * Authentication: Plain
  1647. * Port: 993
  1648. **** Outgoing (SMTP) server settings
  1649. * Select settings/account settings
  1650. * Select Sending mail/outgoing server
  1651. * Set SMTP server to your domain name
  1652. * Set Security to SSL/TLS (always)
  1653. * Set port to 465
  1654. * Set authentication to PLAIN
  1655. * Enter your username and password
  1656. * Accept the SSL certificate
  1657. **** Folders
  1658. To view any new folders which you may have created using the /mailinglistrule/ script from your inbox press the *K9 icon* at the top left to access folders, then press the *menu button* and select *refresh folder list*.
  1659. If your folder still doesn't show up then press the *menu button*, select *show folders* and select *all folders*.
  1660. *** Webmail
  1661. #+BEGIN_VERSE
  1662. /Most of the information extracted is "content", such as recordings of phone calls or the substance of email messages./
  1663. -- From a 2013 Guardian article on GCHQ/NSA bulk internet data interception.
  1664. #+END_VERSE
  1665. 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.
  1666. Install dependencies.
  1667. #+BEGIN_SRC: bash
  1668. apt-get install libapache2-mod-authz-unixgroup
  1669. #+END_SRC
  1670. Create a mysql database, specifying a password which should be a long random string generated with a password manager such as KeepassX.
  1671. #+BEGIN_SRC: bash
  1672. mysql -u root -p
  1673. create database roundcubemail;
  1674. CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'roundcubepassword';
  1675. GRANT ALL PRIVILEGES ON roundcubemail.* TO 'roundcube'@'localhost';
  1676. quit
  1677. #+END_SRC
  1678. Download roundcube.
  1679. #+BEGIN_SRC: bash
  1680. cd /tmp
  1681. wget http://freedombone.uk.to/roundcubemail.tar.gz
  1682. #+END_SRC
  1683. Verify it.
  1684. #+BEGIN_SRC: bash
  1685. sha256sum roundcubemail.tar.gz
  1686. e8a311b22a8e1f70abb72ed9551cc9233cf6c5221f1eebf1ae64974117e3148b roundcubemail.tar.gz
  1687. #+END_SRC
  1688. Extract the files.
  1689. #+BEGIN_SRC: bash
  1690. tar -xzvf roundcubemail.tar.gz
  1691. export HOSTNAME=mydomainname.com
  1692. cp -r roundcubemail-* /var/www/$HOSTNAME/htdocs/mail
  1693. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/mail/temp
  1694. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/mail/logs
  1695. rm /var/www/$HOSTNAME/htdocs/mail/.htaccess
  1696. #+END_SRC
  1697. Edit your web site configuration.
  1698. #+BEGIN_SRC: bash
  1699. emacs /etc/apache2/sites-available/$HOSTNAME
  1700. #+END_SRC
  1701. Within the 80 VirtualHost section add the following:
  1702. #+BEGIN_SRC: bash
  1703. <Directory /var/www/mydomainname.com/htdocs/mail>
  1704. deny from all
  1705. </Directory>
  1706. #+END_SRC
  1707. Within the 443 VirtualHost section add the following:
  1708. #+BEGIN_SRC: bash
  1709. <Directory /var/www/mydomainname.com/htdocs/mail>
  1710. Options Indexes FollowSymLinks MultiViews
  1711. AllowOverride All
  1712. Order allow,deny
  1713. allow from all
  1714. </Directory>
  1715. #+END_SRC
  1716. Save and exit, then restart Apache.
  1717. #+BEGIN_SRC: bash
  1718. service apache2 restart
  1719. #+END_SRC
  1720. Now with a browser visit https://mydomainname.com/mail/installer. Scroll down and click "next". Give your webmail site a product name.
  1721. The *spellcheck_engine* option being limited to Google is slightly concerning in terms of privacy and security, but seems not to be implemented.
  1722. Change the *database password* to the password you gave when creating the MySql database above.
  1723. Set *smtp_port* to 465.
  1724. Click *create config*
  1725. Click download to download the file.
  1726. In a terminal on your local machine (not logged into the BBB):
  1727. #+BEGIN_SRC: bash
  1728. cd ~/Downloads
  1729. scp config.inc.php myusername@mydomainname.com:/home/myusername
  1730. #+END_SRC
  1731. Then in a terminal ssh'd into the BBB:
  1732. #+BEGIN_SRC: bash
  1733. mv /home/myusername/config.inc.php /var/www/$HOSTNAME/htdocs/mail/config
  1734. chmod 755 /var/www/$HOSTNAME/htdocs/mail/config/config.inc.php
  1735. #+END_SRC
  1736. Click *continue*.
  1737. Click *initialize database*.
  1738. Under *Test SMTP config* you can use a [[mailinator.com]] address to check that mail can be sent.
  1739. Now we can delete the installer.
  1740. #+BEGIN_SRC: bash
  1741. rm -rf /var/www/$HOSTNAME/htdocs/mail/installer
  1742. #+END_SRC
  1743. Now with a browser navigate to https://mydomainname.com/mail and log in.
  1744. You'll notice that you may not be able to see any mailing list folders which you may have created earlier using the /mailinglistrule/ script. To make folders visible click on the cog-like settings icon at the bottom left of the screen then select *manage folders*. You will then be able to select which folders you wish to become visible. Make sure that the *Sent*, *spam* and *ham* folders are selected.
  1745. Click on the *Mail* icon to go back to your main mail screen then click on the *Settings* icon at the top right of the screen and select *special folders*. Set *Junk* to *spam* then click the save button. Also select *identities* and make sure that your email address is correct.
  1746. *** Thunderbird
  1747. #+BEGIN_VERSE
  1748. /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./
  1749. -- Brian Spector, on the shutting down of the PrivateSky encrypted email service
  1750. #+END_VERSE
  1751. 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.
  1752. The following instructions should be carried out on the client machines (laptop, etc), not on the BBB itself.
  1753. **** Initial setup
  1754. Install *Thunderbird* and *Enigmail*. How you do this just depends upon your distro and software manager or "app store".
  1755. Open Thinderbird
  1756. Select "*Skip this and use existing email*"
  1757. Enter your name, email address (myusername@mydomainname.com) and the password for your user (the one from [[Add a user]]).
  1758. You'll get a message saying "/Thunderbird failed to find the settings/"
  1759. The settings should be as follows, substituting /mydomainname.com/ for your domain name and /myusername/ for the username given previously in [[Add a user]].
  1760. * Incoming: IMAP, mydomainname.com, 993, SSL/TLS, Normal Password
  1761. * Outgoing: SMTP, mydomainname.com, 465, SSL/TLS, Normal Password
  1762. * Username: myusername
  1763. Click *Done*.
  1764. Click *Get Certificate* and make sure "*permanently store this exception*" is selected", then click *Store Security Exception*.
  1765. 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.
  1766. Select "*Yes, I want to sign all of my email*"
  1767. Select "*No, I will create per-recipient rules*"
  1768. Select "*yes*" to change default settings.
  1769. **** If you have existing GPG key
  1770. Export your GPG public and private keys.
  1771. #+BEGIN_SRC: bash
  1772. gpg --output ~/public_key.txt --armor --export KEY_ID
  1773. gpg --output ~/private_key.txt --armor --export-secret-key KEY_ID
  1774. #+END_SRC
  1775. Select "*I have existing public and private keys*".
  1776. Select your public and private GPG exported key files.
  1777. Select the account which you want to use and click *Next*, *Next* and *Finish*.
  1778. Remove your exported key files.
  1779. #+BEGIN_SRC: bash
  1780. shred -zu ~/public_key.txt
  1781. shred -zu ~/private_key.txt
  1782. #+END_SRC
  1783. **** If you don't have any existing GPG or PGP key
  1784. Select "*I want to create a new key pair*"
  1785. Enter a passphrase and click *Next* a couple of times.
  1786. Click *Generate Certificate* to generate a revocation certificate.
  1787. Enter the passphrase which you gave previously.
  1788. Click *Finish*
  1789. 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.
  1790. 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.
  1791. **** Using for the first time
  1792. Click on the Thunderbird menu, which looks like three horizontal bars on the right hand side.
  1793. Hover over *preferences* and then *Account settings*.
  1794. Select *Synchronization & Storage*.
  1795. Make sure that *Keep messages for this account on this computer* is unticked, then click *Ok*.
  1796. Click on *Inbox*. Depending upon how much email you have it may take a while to import the subject lines.
  1797. Note that when sending an email for the first time you will also need to accept the SSL certificate.
  1798. 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.
  1799. **** Making folders visible
  1800. By default you won't be able to see any folders which you may have created earlier using the /mailinglistrule/ script. To make folders visible select:
  1801. *Menu*, hover over *Preferences*, select *Account Settings*, select *Server Settings* then click on the *Advanced* button.
  1802. Make sure that "*show only subscribed folders*" is not checked. Then click the *ok* buttons. Folders will be re-scanned, which may take some time depending upon how much email you have, but your folders will then appear.
  1803. ** Install a Blog
  1804. #+BEGIN_VERSE
  1805. /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./
  1806. -- Nick Cohen
  1807. #+END_VERSE
  1808. 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.
  1809. 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.
  1810. Download flatpress.
  1811. #+BEGIN_SRC: bash
  1812. cd /tmp
  1813. wget http://freedombone.uk.to/flatpress.tar.gz
  1814. #+END_SRC
  1815. Verify the download:
  1816. #+BEGIN_SRC: bash
  1817. sha256sum flatpress.tar.gz
  1818. 6312a49aab5aabd6371518dcaf081f489dff04d001bc34b4fe3f2a81170bbd4e flatpress.tar.gz
  1819. #+END_SRC
  1820. Extract and install it.
  1821. #+BEGIN_SRC: bash
  1822. tar -xzvf flatpress.tar.gz
  1823. cd flatpress-*
  1824. cp -r * /var/www/$HOSTNAME/htdocs
  1825. rm -rf flatpress-*
  1826. rm -f flatpress.tar.gz
  1827. #+END_SRC
  1828. 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
  1829. ** Install an IRC server
  1830. #+BEGIN_VERSE
  1831. /Give me the liberty to know, to utter, and to argue freely according to conscience, above all liberties./
  1832. -- John Milton
  1833. #+END_VERSE
  1834. *** Base install
  1835. 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.
  1836. First install some dependencies.
  1837. #+BEGIN_SRC: bash
  1838. apt-get update
  1839. apt-get install build-essential openssl libssl-dev
  1840. #+END_SRC
  1841. Then get the source code for ircd-hybrid.
  1842. #+BEGIN_SRC: bash
  1843. cd /tmp
  1844. mkdir hybrid
  1845. cd hybrid
  1846. apt-get source ircd-hybrid
  1847. #+END_SRC
  1848. Modify the source code to include SSL security.
  1849. #+BEGIN_SRC: bash
  1850. emacs ircd-hybrid-*/debian/rules
  1851. #+END_SRC
  1852. Beneath MAXCLIENTS add the line:
  1853. #+BEGIN_SRC: bash
  1854. USE_OPENSSL = 1
  1855. #+END_SRC
  1856. Then save and exit. Now we can build the debian package for ircd-hybrid and install it.
  1857. #+BEGIN_SRC: bash
  1858. cd ircd-hybrid-*
  1859. dpkg-buildpackage -rfakeroot -uc -b
  1860. cd ..
  1861. dpkg -i ircd-hybrid_*.deb
  1862. #+END_SRC
  1863. 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.
  1864. #+BEGIN_SRC: bash
  1865. emacs /etc/ircd-hybrid/ircd.conf
  1866. #+END_SRC
  1867. Set *name* to the name of your server, and set a description.
  1868. Set a *network_name* and *network_desc*. The network name should not contain any spaces.
  1869. Set max_clients to 20, or however many you expect that you'll typically need.
  1870. Within the admin section set your *name* and *email*.
  1871. Within the *listen* section set host to your fixed IP address (in the earlier
  1872. sections it was 192.168.1.60).
  1873. Within the *auth* section set user = "*@192.168.1.60" - or whatever the fixed IP address of the BBB is on your network.
  1874. 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.
  1875. Save and exit, then restart the IRC server. Open port 6670 on your internet router and forward it to the BBB.
  1876. Ensure that the configuration is only readable by the root user.
  1877. #+BEGIN_SRC: bash
  1878. chmod 600 /etc/ircd-hybrid/ircd.conf
  1879. #+END_SRC
  1880. *** Channel management
  1881. To to install channel management tools.
  1882. #+BEGIN_SRC: bash
  1883. cd /tmp
  1884. wget http://freedombone.uk.to/hybserv_1.9.4-1_armhf.deb
  1885. #+END_SRC
  1886. Verify it.
  1887. #+BEGIN_SRC: bash
  1888. sha256sum hybserv_1.9.4-1_armhf.deb
  1889. 41bf4eb6e24c87610a80bc14db1103a57484835510eea7e4ba9709c523318615 hybserv_1.9.4-1_armhf.deb
  1890. #+END_SRC
  1891. Install it.
  1892. #+BEGIN_SRC: bash
  1893. dpkg -i hybserv_1.9.4-1_armhf.deb
  1894. #+END_SRC
  1895. Make a md5 version of the password for the IRC server operator.
  1896. #+BEGIN_SRC: bash
  1897. /usr/bin/mkpasswd <myoperatorpassword>
  1898. #+END_SRC
  1899. Edit the ircd-hybrid configuration.
  1900. #+BEGIN_SRC: bash
  1901. emacs /etc/ircd-hybrid/ircd.conf
  1902. #+END_SRC
  1903. Enter the md5 password which you previously created within the /operator/ section. Also change /user/ to:
  1904. #+BEGIN_SRC: bash
  1905. user = "*@*";
  1906. #+END_SRC
  1907. Then save and exit.
  1908. #+BEGIN_SRC: bash
  1909. emacs /etc/hybserv/hybserv.conf
  1910. #+END_SRC
  1911. 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/.
  1912. #+BEGIN_SRC: bash
  1913. A:mynickname <myemailaddress>
  1914. N:irc.mydomainname.com:Hybrid services
  1915. O:*@*:#MD5 PASSWORD HERE#:root:segj (comment out other Q: lines)
  1916. S:mysendacceptpassword:192.168.1.60:6670 (remove the other two services)
  1917. #+END_SRC
  1918. Also remove the line *#NOT-EDITED#*, then save and exit.
  1919. Now we need to restart the ircd and hybrid server to make things work:
  1920. #+BEGIN_SRC: bash
  1921. service ircd-hybrid restart
  1922. service hybserv start
  1923. #+END_SRC
  1924. *** Usage with Irssi
  1925. On another computer (not the BBB).
  1926. #+BEGIN_SRC: bash
  1927. sudo apt-get install irssi
  1928. irssi
  1929. #+END_SRC
  1930. Connect to the IRC and identify yourself as an operator. Here /mynetwork/ should be the same as *network_name* specified earlier within /ircd.conf/. The network name is something equivalent to "freenode".
  1931. #+BEGIN_SRC: bash
  1932. /network add -nick mynick mynetwork
  1933. /channel add -auto #mychannel mynetwork channelpassword
  1934. /server add -auto -network mynetwork -ssl mydonainname.com 6670 mysendacceptpassword
  1935. /connect mydomainname.com
  1936. /join #mychannel
  1937. /msg -servername chanserv REGISTER #mychannel channelpassword
  1938. /msg -servername chanserv set #mychannel mlock +k channelpassword
  1939. #+END_SRC
  1940. If you edit the irssi config file:
  1941. #+BEGIN_SRC: bash
  1942. emacs ~/.irssi/config
  1943. #+END_SRC
  1944. It should look something like this:
  1945. #+BEGIN_SRC: bash
  1946. {
  1947. address = "mydomainname.com";
  1948. chatnet = "mynetwork";
  1949. port = "6670";
  1950. password = "mysendacceptpassword";
  1951. use_ssl = "yes";
  1952. ssl_verify = "no";
  1953. autoconnect = "yes";
  1954. },
  1955. #+END_SRC
  1956. If you're not using a self-signed certificate (self-signed is the default) then you can set *ssl_verify* to "yes".
  1957. By default Irssi does not look especially attractive. To improve it's looks:
  1958. #+BEGIN_SRC: bash
  1959. cd ~/.irssi
  1960. wget http://freedombone.uk.to/irssi/xchat.theme
  1961. mkdir ~/.irssi/scripts
  1962. mkdir ~/.irssi/scripts/autorun
  1963. cd ~/.irssi/scripts/autorun
  1964. wget http://freedombone.uk.to/irssi/xchatnickcolor.pl
  1965. wget http://freedombone.uk.to/irssi/adv_windowlist.pl
  1966. #+END_SRC
  1967. Verify the files:
  1968. #+BEGIN_SRC: bash
  1969. sha256sum ~/.irssi/xchat.theme
  1970. 7a84130ad55aabd0b043a03b013628438e6c7f82a58e15267633bc7eb443e60b
  1971. sha256sum ~/.irssi/scripts/autorun/xchatnickcolor.pl
  1972. 8293e867a22d42ce5a28cd755237509b6f3587fd2b21d7d20af4a832081610ca
  1973. sha256sum ~/.irssi/scripts/autorun/adv_windowlist.pl
  1974. e4dd8f6d384bf4f2d0ab5ccf06df06e4a69d2647b08d37c8fc6cfd9326688395
  1975. #+END_SRC
  1976. Then run Irssi and enter the commands:
  1977. #+BEGIN_SRC: bash
  1978. /set theme xchat
  1979. /statusbar window remove act
  1980. /set awl
  1981. /set awl_block -14
  1982. /set awl_display_key $Q%K|$N%n $H$C$S
  1983. /set awl_display_key_active $Q%K|$N%n $H%U$C%n$S
  1984. /set awl_display_nokey [$N]$H$C$S
  1985. /run autorun/adv_windowlist.pl
  1986. /set awl_viewer off
  1987. /save
  1988. #+END_SRC
  1989. *** Usage with XChat
  1990. Within the network list click, *Add* and enter your domain name then click *Edit*.
  1991. Select the entry within the servers box, then enter *mydomainname.com/6670* and press *Enter*.
  1992. Uncheck *use global user information*.
  1993. Enter first and second nicknames and check *auto connect to this network on startup*.
  1994. Check *use SSL* and *accept invalid SSL certificate*.
  1995. Enter some favourite channels and within *server password* enter /mysendacceptpassword/ which you defined earlier when setting up the server.
  1996. Click *close* and then *connect*.
  1997. *** Install Irssi as a daemon
  1998. It may be useful to run a persistent Irssi session on the BBB. This will enable you to log in and see any entries which occurred previously so that you don't find yourself in an argument without knowledge of what was said in the last few minutes or hours. This feature only works for a single user on the BBB - typically the administrator.
  1999. First install some prerequisites.
  2000. #+BEGIN_SRC: bash
  2001. apt-get install irssi screen
  2002. #+END_SRC
  2003. Create an initialisation script.
  2004. #+BEGIN_SRC: bash
  2005. emacs /etc/init.d/irssid
  2006. #+END_SRC
  2007. Add the following:
  2008. #+BEGIN_SRC: bash
  2009. #!/bin/bash
  2010. ### BEGIN INIT INFO
  2011. # Provides: irssid
  2012. # Required-Start: $network
  2013. # Required-Stop: $network
  2014. # Default-Start: 2 3 4 5
  2015. # Default-Stop: 0 1 6
  2016. # Short-Description: Start irssi daemon within screen session at boot time
  2017. # Description: This init script will start an irssi session under screen using the settings provided in /etc/irssid.conf
  2018. ### END INIT INFO
  2019. # Include the LSB library functions
  2020. . /lib/lsb/init-functions
  2021. # Setup static variables
  2022. configFile='/etc/irssid.conf'
  2023. daemonExec='/usr/bin/screen'
  2024. daemonArgs='-D -m'
  2025. daemonName="$(basename "$daemonExec")"
  2026. pidFile='/var/run/irssid.pid'
  2027. #
  2028. # Checks if the environment is capable of running the script (such as
  2029. # availability of programs etc).
  2030. #
  2031. # Return: 0 if the environmnt is properly setup for execution of init script, 1
  2032. # if not all conditions have been met.
  2033. #
  2034. function checkEnvironment() {
  2035. # Verify that the necessary binaries are available for execution.
  2036. local binaries=(irssi screen)
  2037. for bin in "${binaries[@]}"; do
  2038. if ! which "$bin" > /dev/null; then
  2039. log_failure_msg "Binary '$bin' is not available. Please install \
  2040. package containing it."
  2041. exit 5
  2042. fi
  2043. done
  2044. }
  2045. #
  2046. # Checks if the configuration files are available and properly setup.
  2047. #
  2048. # Return: 0 if irssid if properly configured, 1 otherwise.
  2049. #
  2050. function checkConfig() {
  2051. # Make sure the configuration file has been created
  2052. if ! [[ -f $configFile ]]; then
  2053. log_failure_msg "Please populate the configuration file '$configFile' \
  2054. before running."
  2055. exit 6
  2056. fi
  2057. # Make sure the required options have been set
  2058. local reqOptions=(user group session)
  2059. for option in "${reqOptions[@]}"; do
  2060. if ! grep -q -e "^[[:blank:]]*$option=" "$configFile"; then
  2061. log_failure_msg "Mandatory option '$option' was not specified in \
  2062. '$configFile'"
  2063. exit 6
  2064. fi
  2065. done
  2066. }
  2067. #
  2068. # Loads the configuration file and performs any additional configuration steps.
  2069. #
  2070. function configure() {
  2071. . "$configFile"
  2072. daemonArgs="$daemonArgs -S $session irssi"
  2073. [[ -n $args ]] && daemonArgs="$daemonArgs $args"
  2074. daemonCommand="$daemonExec $daemonArgs"
  2075. }
  2076. #
  2077. # Starts the daemon.
  2078. #
  2079. # Return: LSB-compliant code.
  2080. #
  2081. function start() {
  2082. start-stop-daemon --start --quiet --oknodo --pidfile "$pidFile" \
  2083. --make-pidfile --chuid "$user:$group" --background \
  2084. --exec "$daemonExec" -- $daemonArgs
  2085. }
  2086. #
  2087. # Stops the daemon.
  2088. #
  2089. # Return: LSB-compliant code.
  2090. #
  2091. function stop() {
  2092. start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile "$pidFile" \
  2093. --chuid "$user:$group" --exec "$daemonExec" -- $daemonArgs
  2094. }
  2095. checkEnvironment
  2096. checkConfig
  2097. configure
  2098. case "$1" in
  2099. start)
  2100. log_daemon_msg "Starting daemon" "irssid"
  2101. start && log_end_msg 0 || log_end_msg $?
  2102. ;;
  2103. stop)
  2104. log_daemon_msg "Stopping daemon" "irssid"
  2105. stop && log_end_msg 0 || log_end_msg $?
  2106. ;;
  2107. restart)
  2108. log_daemon_msg "Restarting daemon" "irssid"
  2109. stop
  2110. start && log_end_msg 0 || log_end_msg $?
  2111. ;;
  2112. force-reload)
  2113. log_daemon_msg "Restarting daemon" "irssid"
  2114. stop
  2115. start && log_end_msg 0 || log_end_msg $?
  2116. ;;
  2117. status)
  2118. status_of_proc -p "$pidFile" "$daemonExec" screen && exit 0 || exit $?
  2119. ;;
  2120. *)
  2121. echo "irssid (start|stop|restart|force-reload|status|help)"
  2122. ;;
  2123. esac
  2124. #+END_SRC
  2125. Save and exit.
  2126. #+BEGIN_SRC: bash
  2127. chmod +x /etc/init.d/irssid
  2128. #+END_SRC
  2129. Create a configuration file, replacing /myusername/ with your username.
  2130. #+BEGIN_SRC: bash
  2131. emacs /etc/irssid.conf
  2132. #+END_SRC
  2133. #+BEGIN_SRC: bash
  2134. #
  2135. # Configuration file for irssid init script
  2136. #
  2137. # Mandatory options:
  2138. #
  2139. # user - Specify user for running irssi.
  2140. # group - Specify group for running irssi.
  2141. # session - Specify screen session name to be used for irssi.
  2142. #
  2143. # Non-mandatory options:
  2144. #
  2145. # args - Pass additional arguments to irssi.
  2146. #
  2147. user='myusername'
  2148. group='irssi'
  2149. session='irssi'
  2150. args='--config /home/myusername/.irssi/config'
  2151. #+END_SRC
  2152. Save and exit. Then add your user to the irssi group and start the daemon.
  2153. #+BEGIN_SRC: bash
  2154. groupadd irssi
  2155. usermod -aG irssi myusername
  2156. update-rc.d irssid defaults
  2157. service irssid start
  2158. #+END_SRC
  2159. Create a script to make running IRC on the server easier.
  2160. #+BEGIN_SRC: bash
  2161. emacs /usr/bin/irc
  2162. #+END_SRC
  2163. Add the following:
  2164. #+BEGIN_SRC: bash
  2165. #!/bin/bash
  2166. screen -r irssi
  2167. #+END_SRC
  2168. Save and exit.
  2169. #+BEGIN_SRC: bash
  2170. chmod +x /usr/bin/irc
  2171. chown myusername:myusername /usr/bin/irc
  2172. #+END_SRC
  2173. Then to subsequently access irssi log into the BBB using ssh and type:
  2174. #+BEGIN_SRC: bash
  2175. irc
  2176. #+END_SRC
  2177. ** Install a Jabber/XMPP server
  2178. #+BEGIN_VERSE
  2179. /Well heck, it isn’t that hard to write an instant messaging system./
  2180. --Jeremie Miller
  2181. #+END_VERSE
  2182. *** The Server
  2183. Generate a SSL certificate.
  2184. #+BEGIN_SRC: bash
  2185. openssl ecparam -out /etc/ssl/private/xmpp.pem -name prime256v1
  2186. openssl genpkey -paramfile /etc/ssl/private/xmpp.pem -out /etc/ssl/private/xmpp.key
  2187. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  2188. #+END_SRC
  2189. 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:
  2190. #+BEGIN_SRC: bash
  2191. openssl genrsa -out /etc/ssl/private/xmpp.key 4096
  2192. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  2193. #+END_SRC
  2194. Change permissions.
  2195. #+BEGIN_SRC: bash
  2196. chmod 600 /etc/ssl/private/xmpp.key
  2197. chmod 600 /etc/ssl/certs/xmpp.crt
  2198. chown prosody:prosody /etc/ssl/private/xmpp.key
  2199. chown prosody:prosody /etc/ssl/certs/xmpp.crt
  2200. #+END_SRC
  2201. Install Prosody.
  2202. #+BEGIN_SRC: bash
  2203. apt-get install prosody
  2204. cp -a /etc/prosody/conf.avail/example.com.cfg.lua /etc/prosody/conf.avail/xmpp.cfg.lua
  2205. emacs /etc/prosody/conf.avail/xmpp.cfg.lua
  2206. #+END_SRC
  2207. Change the *VirtualHost* name to your domain name and remove the line below it.
  2208. Set the ssl section to:
  2209. #+BEGIN_SRC: bash
  2210. ssl = {
  2211. key = "/etc/ssl/private/xmpp.key";
  2212. certificate = "/etc/ssl/certs/xmpp.crt";
  2213. }
  2214. #+END_SRC
  2215. And also append the following:
  2216. #+BEGIN_SRC: bash
  2217. modules_enabled = {
  2218. "bosh"; -- Enable mod_bosh
  2219. "tls"; -- Enable mod_tls
  2220. }
  2221. c2s_require_encryption = true
  2222. s2s_require_encryption = true
  2223. #+END_SRC
  2224. Save and exit. Create a symbolic link.
  2225. #+BEGIN_SRC: bash
  2226. ln -sf /etc/prosody/conf.avail/xmpp.cfg.lua /etc/prosody/conf.d/xmpp.cfg.lua
  2227. #+END_SRC
  2228. 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).
  2229. #+BEGIN_SRC: bash
  2230. prosodyctl adduser myusername@mydomainname.com
  2231. #+END_SRC
  2232. Restart the server
  2233. #+BEGIN_SRC: bash
  2234. service prosody restart
  2235. #+END_SRC
  2236. On your internet router/firewall open ports 5222, 5223, 5269, 5280 and 5281 and forward them to the BBB.
  2237. 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.
  2238. *** Managing users
  2239. To add a user:
  2240. #+BEGIN_SRC: bash
  2241. prosodyctl adduser myusername@mydomainname.com
  2242. #+END_SRC
  2243. To change a user password:
  2244. #+BEGIN_SRC: bash
  2245. prosodyctl passwd myusername@mydomainname.com
  2246. #+END_SRC
  2247. To remove a user:
  2248. #+BEGIN_SRC: bash
  2249. prosodyctl deluser myusername@mydomainname.com
  2250. #+END_SRC
  2251. Report the status of the XMPP server:
  2252. #+BEGIN_SRC: bash
  2253. prosodyctl status
  2254. #+END_SRC
  2255. *** Using with Jitsi
  2256. 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.
  2257. Jitsi can be downloaded from https://jitsi.org/
  2258. On your desktop/laptop open Jitsi and select *Options* from the *Tools* menu.
  2259. 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).
  2260. 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.
  2261. 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.
  2262. You can also [[https://www.youtube.com/watch?v=vgx7VSrDGjk][see this video]] as an example of using OTR.
  2263. *** Using with Ubuntu
  2264. 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.
  2265. Open *System Settings* and select *Online Accounts*, *Add account* and then *Jabber*.
  2266. Enter your username (myusername@mydomainname.com) and password.
  2267. 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*.
  2268. *** Using with Android
  2269. There are a few XMPP clients available on Android. Ideally choose ones which support off-the-record messaging. Here are some examples.
  2270. **** Xabber
  2271. Install [[https://f-droid.org/][F-Droid]]
  2272. Search for and install Xabber.
  2273. Add an account and enter your Jabber/XMPP ID and password.
  2274. From the menu select *Settings* then *Security* then *OTR mode*. Set the mode to *Required*.
  2275. Make sure that *Check server certificate* is not checked.
  2276. 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.
  2277. **** Gibberbot
  2278. Install [[https://f-droid.org/][F-Droid]]
  2279. Search for and install Gibberbot, otherwise known as ChatSecure.
  2280. From the menu open *Accounts*
  2281. Select *Add account*
  2282. Change the server port from 0 to 5222
  2283. Done
  2284. Accept unknown certificate? Select *Always*
  2285. Go back to the initial screen and then using the menu you can add contacts and begin chatting.
  2286. ** Social Networking
  2287. #+BEGIN_VERSE
  2288. /Facebook is not your friend, it is a surveillance engine./
  2289. -- Richard Stallman, Free Software Foundation
  2290. #+END_VERSE
  2291. *** Friendica
  2292. **** Installation
  2293. 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.
  2294. 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:
  2295. #+BEGIN_SRC: bash
  2296. emacs /etc/apache2/sites-available/mydomainname.com
  2297. #+END_SRC
  2298. Within the section which begins with *<VirtualHost *:80>* change the following:
  2299. #+BEGIN_SRC: bash
  2300. <Directory /var/www/mydomainname.com/htdocs/>
  2301. deny from all
  2302. </Directory>
  2303. #+END_SRC
  2304. Save and exit, then restart the apache server.
  2305. #+BEGIN_SRC: bash
  2306. service apache2 restart
  2307. #+END_SRC
  2308. Now install some dependencies.
  2309. #+BEGIN_SRC: bash
  2310. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  2311. #+END_SRC
  2312. Enter an admin password for MySQL.
  2313. Create a mysql database.
  2314. #+BEGIN_SRC: bash
  2315. mysql -u root -p
  2316. create database friendica;
  2317. CREATE USER 'friendicaadmin'@'localhost' IDENTIFIED BY 'password';
  2318. GRANT ALL PRIVILEGES ON friendica.* TO 'friendicaadmin'@'localhost';
  2319. quit
  2320. #+END_SRC
  2321. You may need to fix Git SSL problems.
  2322. #+BEGIN_SRC: bash
  2323. git config --global http.sslVerify true
  2324. apt-get install ca-certificates
  2325. cd ~/
  2326. emacs .gitconfig
  2327. #+END_SRC
  2328. The .gitconfig file should look something like this:
  2329. #+BEGIN_SRC: bash
  2330. [http]
  2331. sslVerify = true
  2332. sslCAinfo = /etc/ssl/certs/ca-certificates.crt
  2333. [user]
  2334. email = myusername@mydomainname.com
  2335. name = yourname
  2336. #+END_SRC
  2337. Get the source code.
  2338. #+BEGIN_SRC: bash
  2339. export HOSTNAME=mydomainname.com
  2340. cd /var/www/$HOSTNAME
  2341. mv htdocs htdocs_old
  2342. git clone https://github.com/friendica/friendica.git htdocs
  2343. chmod -R 755 htdocs
  2344. chown -R www-data:www-data htdocs
  2345. chown -R www-data:www-data htdocs/view/smarty3
  2346. git clone https://github.com/friendica/friendica-addons.git htdocs/addon
  2347. #+END_SRC
  2348. 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.
  2349. Install the poller.
  2350. #+BEGIN_SRC: bash
  2351. emacs /etc/crontab
  2352. #+END_SRC
  2353. and append the following, changing mydomainname.com to whatever your domain is.
  2354. #+BEGIN_SRC: bash
  2355. */10 * * * * root cd /var/www/mydomainname.com/htdocs; /usr/bin/timeout 120 /usr/bin/php include/poller.php
  2356. #+END_SRC
  2357. Save and exit, then restart cron.
  2358. #+BEGIN_SRC: bash
  2359. service cron restart
  2360. #+END_SRC
  2361. You can improve the speed of Friendica database searches by adding the following indexes:
  2362. #+BEGIN_SRC: bash
  2363. mysql -u root -p
  2364. use friendica;
  2365. CREATE INDEX `uri_received` ON item(`uri`, `received`);
  2366. CREATE INDEX `received_uri` ON item(`received`, `uri`);
  2367. CREATE INDEX `contact-id_created` ON item(`contact-id`, created);
  2368. CREATE INDEX `uid_network_received` ON item(`uid`, `network`, `received`);
  2369. CREATE INDEX `uid_parent` ON item(`uid`, `parent`);
  2370. CREATE INDEX `uid_received` ON item(`uid`, `received`);
  2371. CREATE INDEX `uid_network_commented` ON item(`uid`, `network`, `commented`);
  2372. CREATE INDEX `uid_title` ON item(uid, `title`);
  2373. CREATE INDEX `created_contact-id` ON item(`created`, `contact-id`);
  2374. quit
  2375. #+END_SRC
  2376. Make sure that Friendica doesn't use too much memory.
  2377. #+BEGIN_SRC: bash
  2378. emacs /var/www/$HOSTNAME/htdocs/.htaccess
  2379. #+END_SRC
  2380. Append the following:
  2381. #+BEGIN_SRC: bash
  2382. php_value memory_limit 32M
  2383. #+END_SRC
  2384. The save ane exit.
  2385. **** Backups
  2386. 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.
  2387. #+BEGIN_SRC: bash
  2388. emacs /etc/cron.daily/friendicabackup
  2389. #+END_SRC
  2390. Enter the following
  2391. #+BEGIN_SRC: bash
  2392. #!/bin/sh
  2393. MYSQL_PASSWORD=<mysql root password>
  2394. umask 0077
  2395. # Backup the database
  2396. mysqldump --password=$MYSQL_PASSWORD friendica > /var/backups/friendica_daily.sql
  2397. # Make the backup readable only by root
  2398. chmod 600 /var/backups/friendica_daily.sql
  2399. #+END_SRC
  2400. Save and exit.
  2401. #+BEGIN_SRC: bash
  2402. chmod 600 /etc/cron.daily/friendicabackup
  2403. chmod +x /etc/cron.daily/friendicabackup
  2404. emacs /etc/cron.weekly/friendicabackup
  2405. #+END_SRC
  2406. Enter the following
  2407. #+BEGIN_SRC: bash
  2408. #!/bin/sh
  2409. MYSQL_PASSWORD=<mysql root password>
  2410. umask 0077
  2411. # Backup the database
  2412. mysqldump --password=$MYSQL_PASSWORD friendica > /var/backups/friendica_weekly.sql
  2413. # Make the backup readable only by root
  2414. chmod 600 /var/backups/friendica_weekly.sql
  2415. #+END_SRC
  2416. Save and exit.
  2417. #+BEGIN_SRC: bash
  2418. chmod 600 /etc/cron.weekly/friendicabackup
  2419. chmod +x /etc/cron.weekly/friendicabackup
  2420. #+END_SRC
  2421. **** Recommended configuration
  2422. ***** Admin
  2423. 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.
  2424. 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.
  2425. Under the *themes* section select a few themes, including mobile themes which are suitable for phones or tablets.
  2426. 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.
  2427. 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]].
  2428. ***** Settings
  2429. Each user has their own customisable settings, typically available either via an icon or by an entry on a drop down menu.
  2430. Under *additional features* enable "/richtext editor/", "/post preview/", "/group filter/", "/network filter/", "/edit sent posts/" and "/dislike posts/".
  2431. Under *display settings* select your desktop and mobile themes.
  2432. 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.
  2433. **** To access from an Android device
  2434. ***** App
  2435. 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.
  2436. 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.
  2437. More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
  2438. ***** Mobile Theme
  2439. 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.
  2440. *** Movim
  2441. #+BEGIN_VERSE
  2442. /The way we communicate with others and with ourselves ultimately determines the quality of our lives/
  2443. -- Anthony Robbins
  2444. #+END_VERSE
  2445. Movim is another social networking system based around the XMPP protocol.
  2446. You will need to have previously [[Install a Jabber/XMPP server][installed the Jabber/XMPP server]].
  2447. 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:
  2448. #+BEGIN_SRC: bash
  2449. emacs /etc/apache2/sites-available/mydomainname.com
  2450. #+END_SRC
  2451. Within the section which begins with *<VirtualHost *:80>* add the following:
  2452. #+BEGIN_SRC: bash
  2453. <Directory /var/www/mydomainname.com/htdocs/movim>
  2454. deny from all
  2455. </Directory>
  2456. #+END_SRC
  2457. Within the section which begins with *<VirtualHost *:443>* add the following:
  2458. #+BEGIN_SRC: bash
  2459. <Directory /var/www/mydomainname.com/htdocs/movim>
  2460. Options Indexes FollowSymLinks MultiViews
  2461. AllowOverride All
  2462. Order allow,deny
  2463. allow from all
  2464. </Directory>
  2465. #+END_SRC
  2466. Save and exit, then restart the apache server.
  2467. #+BEGIN_SRC: bash
  2468. service apache2 restart
  2469. #+END_SRC
  2470. Download the source.
  2471. #+BEGIN_SRC: bash
  2472. cd /tmp
  2473. wget http://freedombone.uk.to/movim.tar.gz
  2474. #+END_SRC
  2475. Verify it.
  2476. #+BEGIN_SRC: bash
  2477. sha256sum movim.tar.gz
  2478. 2740ddbedf6cefcc2934759374376643b6cdea4fb7f944ec25098a6868cb499e movim.tar.gz
  2479. #+END_SRC
  2480. Install it.
  2481. #+BEGIN_SRC: bash
  2482. tar -xzvf movim.tar.gz
  2483. export HOSTNAME=mydomainname.com
  2484. cp -r movim-* /var/www/$HOSTNAME/htdocs/movim
  2485. chmod 755 /var/www/$HOSTNAME/htdocs/movim
  2486. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/movim
  2487. #+END_SRC
  2488. Install some MySql prerequisites.
  2489. #+BEGIN_SRC: bash
  2490. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  2491. #+END_SRC
  2492. If necessary, enter an admin password for MySQL.
  2493. Create a mysql database.
  2494. #+BEGIN_SRC: bash
  2495. mysql -u root -p
  2496. create database movim;
  2497. CREATE USER 'movimadmin'@'localhost' IDENTIFIED BY 'movimadminpassword';
  2498. GRANT ALL PRIVILEGES ON movim.* TO 'movimadmin'@'localhost';
  2499. quit
  2500. #+END_SRC
  2501. With a web browser navigate to:
  2502. https://mydomainname.com/movim/admin
  2503. Enter /admin/ as the username and /password/ as the password.
  2504. 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).
  2505. Change the /Environment/ from /Development/ to /Production/.
  2506. 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?)
  2507. Click /Submit/ followed by /Resend/.
  2508. Click on /Database Settings/ and alter the MySql movim database username to /movimadmin/ and password to the password you specified in the previous step.
  2509. 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".
  2510. 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).
  2511. *** Red Matrix
  2512. **** Introduction
  2513. 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.
  2514. **** Prerequisites
  2515. 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.
  2516. 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.
  2517. **** Installation
  2518. 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.
  2519. 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:
  2520. #+BEGIN_SRC: bash
  2521. emacs /etc/apache2/sites-available/mydomainname.com
  2522. #+END_SRC
  2523. Within the section which begins with *<VirtualHost *:80>* change the following:
  2524. #+BEGIN_SRC: bash
  2525. <Directory /var/www/mydomainname.com/htdocs/>
  2526. deny from all
  2527. </Directory>
  2528. #+END_SRC
  2529. Save and exit, then restart the apache server.
  2530. #+BEGIN_SRC: bash
  2531. service apache2 restart
  2532. #+END_SRC
  2533. Now install some dependencies.
  2534. #+BEGIN_SRC: bash
  2535. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  2536. #+END_SRC
  2537. Enter an admin password for MySQL.
  2538. Create a mysql database.
  2539. #+BEGIN_SRC: bash
  2540. mysql -u root -p
  2541. create database redmatrix;
  2542. CREATE USER 'redmatrixadmin'@'localhost' IDENTIFIED BY 'password';
  2543. GRANT ALL PRIVILEGES ON redmatrix.* TO 'redmatrixadmin'@'localhost';
  2544. quit
  2545. #+END_SRC
  2546. You may need to fix Git SSL problems.
  2547. #+BEGIN_SRC: bash
  2548. git config --global http.sslVerify true
  2549. apt-get install ca-certificates
  2550. cd ~/
  2551. emacs .gitconfig
  2552. #+END_SRC
  2553. The .gitconfig file should look something like this:
  2554. #+BEGIN_SRC: bash
  2555. [http]
  2556. sslVerify = true
  2557. sslCAinfo = /etc/ssl/certs/ca-certificates.crt
  2558. [user]
  2559. email = myusername@mydomainname.com
  2560. name = yourname
  2561. #+END_SRC
  2562. Get the source code.
  2563. #+BEGIN_SRC: bash
  2564. export HOSTNAME=mydomainname.com
  2565. cd /var/www/$HOSTNAME
  2566. mv htdocs htdocs_old
  2567. git clone https://github.com/friendica/red.git htdocs
  2568. chmod -R 755 htdocs
  2569. chown -R www-data:www-data htdocs
  2570. mkdir htdocs/view/tpl/smarty3
  2571. chmod 777 htdocs/view/tpl
  2572. chmod 777 htdocs/view/tpl/smarty3
  2573. git clone https://github.com/friendica/red-addons.git htdocs/addon
  2574. #+END_SRC
  2575. 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.
  2576. Install the poller.
  2577. #+BEGIN_SRC
  2578. emacs /etc/crontab
  2579. #+END_SRC
  2580. and append the following, changing mydomainname.com to whatever your domain is.
  2581. #+BEGIN_SRC
  2582. */10 * * * * root cd /var/www/mydomainname.com/htdocs; /usr/bin/php include/poller.php
  2583. #+END_SRC
  2584. Save and exit, then restart cron.
  2585. #+BEGIN_SRC: bash
  2586. service cron restart
  2587. #+END_SRC
  2588. **** Backups
  2589. 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.
  2590. #+BEGIN_SRC: bash
  2591. emacs /etc/cron.daily/redmatrixbackup
  2592. #+END_SRC
  2593. Enter the following
  2594. #+BEGIN_SRC: bash
  2595. #!/bin/sh
  2596. MYSQL_PASSWORD=<mysql root password>
  2597. umask 0077
  2598. # Backup the database
  2599. mysqldump --password=$MYSQL_PASSWORD redmatrix > /var/backups/redmatrix_daily.sql
  2600. # Make the backup readable only by root
  2601. chmod 600 /var/backups/redmatrix_daily.sql
  2602. #+END_SRC
  2603. Save and exit.
  2604. #+BEGIN_SRC: bash
  2605. chmod 600 /etc/cron.daily/redmatrixbackup
  2606. chmod +x /etc/cron.daily/redmatrixbackup
  2607. emacs /etc/cron.weekly/redmatrixbackup
  2608. #+END_SRC
  2609. Enter the following
  2610. #+BEGIN_SRC: bash
  2611. #!/bin/sh
  2612. MYSQL_PASSWORD=<mysql root password>
  2613. umask 0077
  2614. # Backup the database
  2615. mysqldump --password=$MYSQL_PASSWORD redmatrix > /var/backups/redmatrix_weekly.sql
  2616. # Make the backup readable only by root
  2617. chmod 600 /var/backups/redmatrix_weekly.sql
  2618. #+END_SRC
  2619. Save and exit.
  2620. #+BEGIN_SRC: bash
  2621. chmod 600 /etc/cron.weekly/redmatrixbackup
  2622. chmod +x /etc/cron.weekly/redmatrixbackup
  2623. #+END_SRC
  2624. **** To access from an Android device
  2625. ***** App
  2626. 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.
  2627. 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.
  2628. More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
  2629. ** Install Gopher
  2630. *** Server setup
  2631. 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.
  2632. To set up a gopher server:
  2633. #+BEGIN_SRC: bash
  2634. apt-get install build-essential
  2635. cd /tmp
  2636. wget http://freedombone.uk.to/geomyidae-current.tgz
  2637. #+END_SRC
  2638. Verify the download:
  2639. #+BEGIN_SRC: bash
  2640. sha256sum geomyidae-current.tgz
  2641. 162f55ab059ab0a9be8e840497795293bbd51c34b1f4564dcdf3f0ddd5c0db31 geomyidae-current.tgz
  2642. #+END_SRC
  2643. Then extract and install it.
  2644. #+BEGIN_SRC: bash
  2645. tar -xzvf geomyidae-current.tgz
  2646. cd geomyidae-*
  2647. make
  2648. make install
  2649. mkdir -p /var/gopher
  2650. #+END_SRC
  2651. 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.
  2652. #+BEGIN_SRC: bash
  2653. emacs /etc/init.d/gopher
  2654. #+END_SRC
  2655. Enter the following:
  2656. #+BEGIN_SRC: bash
  2657. #! /bin/sh
  2658. ### BEGIN INIT INFO
  2659. # Provides: gopher
  2660. # Required-Start: $remote_fs $syslog
  2661. # Required-Stop: $remote_fs $syslog
  2662. # Default-Start: 2 3 4 5
  2663. # Default-Stop: 0 1 6
  2664. # Short-Description: Gopher daemon
  2665. # Description: Gopher daemon
  2666. ### END INIT INFO
  2667. # Do NOT "set -e"
  2668. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  2669. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  2670. DESC="Gopher daemon"
  2671. NAME=geomyidae
  2672. DAEMON=/usr/bin/$NAME
  2673. DAEMON_ARGS="-l /var/log/geomyidae.log -b /var/gopher -p 70"
  2674. PIDFILE=/var/run/$NAME.pid
  2675. SCRIPTNAME=/etc/init.d/$NAME
  2676. # Exit if the package is not installed
  2677. [ -x "$DAEMON" ] || exit 0
  2678. # Read configuration variable file if it is present
  2679. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  2680. # Load the VERBOSE setting and other rcS variables
  2681. . /lib/init/vars.sh
  2682. # Define LSB log_* functions.
  2683. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
  2684. # and status_of_proc is working.
  2685. . /lib/lsb/init-functions
  2686. #
  2687. # Function that starts the daemon/service
  2688. #
  2689. do_start()
  2690. {
  2691. # Return
  2692. # 0 if daemon has been started
  2693. # 1 if daemon was already running
  2694. # 2 if daemon could not be started
  2695. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
  2696. || return 1
  2697. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
  2698. $DAEMON_ARGS \
  2699. || return 2
  2700. # Add code here, if necessary, that waits for the process to be ready
  2701. # to handle requests from services started subsequently which depend
  2702. # on this one. As a last resort, sleep for some time.
  2703. }
  2704. #
  2705. # Function that stops the daemon/service
  2706. #
  2707. do_stop()
  2708. {
  2709. # Return
  2710. # 0 if daemon has been stopped
  2711. # 1 if daemon was already stopped
  2712. # 2 if daemon could not be stopped
  2713. # other if a failure occurred
  2714. start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
  2715. RETVAL="$?"
  2716. [ "$RETVAL" = 2 ] && return 2
  2717. # Wait for children to finish too if this is a daemon that forks
  2718. # and if the daemon is only ever run from this initscript.
  2719. # If the above conditions are not satisfied then add some other code
  2720. # that waits for the process to drop all resources that could be
  2721. # needed by services started subsequently. A last resort is to
  2722. # sleep for some time.
  2723. start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
  2724. [ "$?" = 2 ] && return 2
  2725. # Many daemons don't delete their pidfiles when they exit.
  2726. rm -f $PIDFILE
  2727. return "$RETVAL"
  2728. }
  2729. #
  2730. # Function that sends a SIGHUP to the daemon/service
  2731. #
  2732. do_reload() {
  2733. #
  2734. # If the daemon can reload its configuration without
  2735. # restarting (for example, when it is sent a SIGHUP),
  2736. # then implement that here.
  2737. #
  2738. start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
  2739. return 0
  2740. }
  2741. case "$1" in
  2742. start)
  2743. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  2744. do_start
  2745. case "$?" in
  2746. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  2747. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  2748. esac
  2749. ;;
  2750. stop)
  2751. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  2752. do_stop
  2753. case "$?" in
  2754. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  2755. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  2756. esac
  2757. ;;
  2758. status)
  2759. status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  2760. ;;
  2761. #reload|force-reload)
  2762. #
  2763. # If do_reload() is not implemented then leave this commented out
  2764. # and leave 'force-reload' as an alias for 'restart'.
  2765. #
  2766. #log_daemon_msg "Reloading $DESC" "$NAME"
  2767. #do_reload
  2768. #log_end_msg $?
  2769. #;;
  2770. restart|force-reload)
  2771. #
  2772. # If the "reload" option is implemented then remove the
  2773. # 'force-reload' alias
  2774. #
  2775. log_daemon_msg "Restarting $DESC" "$NAME"
  2776. do_stop
  2777. case "$?" in
  2778. 0|1)
  2779. do_start
  2780. case "$?" in
  2781. 0) log_end_msg 0 ;;
  2782. 1) log_end_msg 1 ;; # Old process is still running
  2783. *) log_end_msg 1 ;; # Failed to start
  2784. esac
  2785. ;;
  2786. *)
  2787. # Failed to stop
  2788. log_end_msg 1
  2789. ;;
  2790. esac
  2791. ;;
  2792. *)
  2793. #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  2794. echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
  2795. exit 3
  2796. ;;
  2797. esac
  2798. :
  2799. #+END_SRC
  2800. Save and exit. Then start the gopher service.
  2801. #+BEGIN_SRC: bash
  2802. chmod +x /etc/init.d/gopher
  2803. update-rc.d gopher defaults
  2804. service gopher start
  2805. #+END_SRC
  2806. 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:
  2807. #+BEGIN_SRC: bash
  2808. gopher://mydomainname.com
  2809. #+END_SRC
  2810. There is a browser addon for Gopher called "overbite". Installing that should enable you to view your site.
  2811. *** A phlogging script
  2812. A phlog is the gopher equivalent of a blog on the web. You can create a script which makes phlogging easy.
  2813. #+BEGIN_SRC: bash
  2814. emacs /usr/bin/mkphlog
  2815. #+END_SRC
  2816. Add the following:
  2817. #+BEGIN_SRC: bash
  2818. #!/bin/sh
  2819. # mkphlog - a utility to ease the creation of phlogs.
  2820. # Organizes phlog posts in separate directories.
  2821. # Created by octotep; anyone can distribute, modify, and
  2822. # share this file however they please.
  2823. #
  2824. # Version 0.3
  2825. #
  2826. # Modified by Bob Mottram
  2827. #
  2828. # Please note, all date strings are in the form of mm/dd/yy(yy)
  2829. # The base of the entire gopher site.
  2830. gopherRoot="/var/gopher"
  2831. # The name of the phlog directory (contained in $gopherHome)
  2832. phlogDirName="phlog"
  2833. # Default editor, unless the user has one specified in env
  2834. editor=${EDITOR:-emacs}
  2835. # Default timezone, unless the user has one specified in env
  2836. TZ=${TZ:-UTC}
  2837. # Tells the script how many lines the title of the main page spans.
  2838. # Used to insert the newest post at the top.
  2839. # Titles created by mkphlog are 3 lines.
  2840. # Isn't used if $addTitleToMain is false
  2841. titleLineCount=3
  2842. entryDate=`date +%Y-%m-%d`
  2843. # Creates the phlog directory if it dosen't already exist.
  2844. CreatePhlogDir() {
  2845. mkdir $phlogDirName
  2846. chmod 755 $phlogDirName
  2847. cd $phlogDirName
  2848. echo "Phlog directory created."
  2849. }
  2850. # Updates the main phlog listing
  2851. UpdatePhlogListing() {
  2852. # Just in case the user didn't specify a title
  2853. if [ "$postTitleAns" = "" ] ; then
  2854. echo -n "Do you want to create a blank post? (y/n) "
  2855. read blankPostAns
  2856. case $blankPostAns in
  2857. y* | Y* ) $postTitleAns="New Post" ;;
  2858. n* | N* ) echo "Goodbye, then." ; exit 1 ;;
  2859. * ) exit 1 ;;
  2860. esac
  2861. fi
  2862. cd $gopherRoot/$phlogDirName/
  2863. title2=$(echo "${postTitleAns}" | tr " " _)
  2864. postfilename="${entryDate}_${title2}.txt"
  2865. touch ${postfilename}
  2866. echo $postTitleAns >> ${postfilename}
  2867. date "+%A %b %e %l:%M:%S %Y" >> ${postfilename}
  2868. echo "------------------------------" >> ${postfilename}
  2869. echo >> ${postfilename}
  2870. }
  2871. if [ -d $gopherRoot ] ; then
  2872. cd $gopherRoot
  2873. else
  2874. echo "You don't have a gopherspace set-up. Please run the gopher server setup instructions."
  2875. exit 1
  2876. fi
  2877. if [ -d $phlogDirName ] ; then
  2878. cd $phlogDirName
  2879. else
  2880. echo -n "Do you want to create a phlog directory? (y/n) "
  2881. read phlogDirAns
  2882. case $phlogDirAns in
  2883. y* | Y* ) CreatePhlogDir ;;
  2884. n* | N* ) exit 1 ;;
  2885. * ) exit 1 ;;
  2886. esac
  2887. fi
  2888. echo -n "Would you like to create a phlog entry for today? (y/n) "
  2889. read phlogAns
  2890. case $phlogAns in
  2891. y* | Y* ) echo "Creating today's phlog entry..." ;;
  2892. n* | N* ) exit 0 ;;
  2893. * ) exit 1 ;;
  2894. esac
  2895. # Make sure there isn't a post for that day, lest we overwrite it.
  2896. if [ ! -d $entryDate ]; then
  2897. echo -n "Title: "
  2898. read postTitleAns
  2899. title2=$(echo "${postTitleAns}" | tr " " _)
  2900. postfilename="${entryDate}_${title2}.txt"
  2901. touch ${postfilename}
  2902. chmod 644 ${postfilename}
  2903. UpdatePhlogListing
  2904. echo -n "Would you like to edit the post with $editor? (y/n) "
  2905. read editorAns
  2906. case $editorAns in
  2907. y* | Y* ) $editor $gopherRoot/$phlogDirName/${postfilename} ;;
  2908. n* | N* ) exit 0 ;;
  2909. * ) exit 0 ;;
  2910. esac
  2911. rm $gopherRoot/$phlogDirName/${postfilename}~
  2912. else
  2913. echo "There is already a post for today."
  2914. echo -n "Would you like to edit the post with $editor? (y/n) "
  2915. read editorAns
  2916. case $editorAns in
  2917. y* | Y* ) $editor $gopherRoot/$phlogDirName/$entryDate*.txt ;;
  2918. n* | N* ) exit 0 ;;
  2919. * ) exit 1 ;;
  2920. esac
  2921. rm $gopherRoot/$phlogDirName/${postfilename}.txt~
  2922. fi
  2923. exit 0
  2924. #+END_SRC
  2925. Save and exit.
  2926. #+BEGIN_SRC: bash
  2927. chmod +x /usr/bin/mkphlog
  2928. #+END_SRC
  2929. Now entering the command /mkphlog/ will allow you to create a phlog entry.
  2930. ** Install Owncloud
  2931. #+BEGIN_VERSE
  2932. /It's not water vapour/
  2933. -- Larry Ellison
  2934. #+END_VERSE
  2935. 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.
  2936. *** Server Installation
  2937. Install some dependencies:
  2938. #+BEGIN_SRC: bash
  2939. apt-get install apache2 php5 php5-gd php-xml-parser php5-intl
  2940. apt-get install php5-sqlite php5-mysql smbclient curl libcurl3 php5-curl
  2941. #+END_SRC
  2942. 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.
  2943. #+BEGIN_SRC: bash
  2944. a2dismod php5filter
  2945. apt-get install libapache2-mod-php5
  2946. #+END_SRC
  2947. Ensure that the size of files which may be uploaded or downloaded is large enough.
  2948. #+BEGIN_SRC: bash
  2949. emacs /etc/php5/apache2/php.ini
  2950. #+END_SRC
  2951. Set the following:
  2952. #+BEGIN_SRC: bash
  2953. upload_max_filesize = 512M
  2954. post_max_size = 512M
  2955. #+END_SRC
  2956. Save and exit, then edit your Apache configuration.
  2957. #+BEGIN_SRC: bash
  2958. export HOSTNAME=mydomainname.com
  2959. emacs /etc/apache2/sites-available/$HOSTNAME
  2960. #+END_SRC
  2961. 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.
  2962. #+BEGIN_SRC: bash
  2963. <Directory /var/www/mydomainname.com/htdocs/owncloud>
  2964. Options Indexes FollowSymLinks MultiViews
  2965. AllowOverride All
  2966. Order allow,deny
  2967. allow from all
  2968. </Directory>
  2969. #+END_SRC
  2970. To ensure that nobody logs in insecurely add the following to the 80 VirtualHost section.
  2971. #+BEGIN_SRC: bash
  2972. <Directory /var/www/mydomainname.com/htdocs/owncloud>
  2973. deny from all
  2974. </Directory>
  2975. #+END_SRC
  2976. Save and exit, then restart apache.
  2977. #+BEGIN_SRC: bash
  2978. service apache2 restart
  2979. #+END_SRC
  2980. Download owncloud.
  2981. #+BEGIN_SRC: bash
  2982. cd /tmp
  2983. wget http://freedombone.uk.to/owncloud.tar.bz2
  2984. #+END_SRC
  2985. Verify the download:
  2986. #+BEGIN_SRC: bash
  2987. sha256sum owncloud.tar.bz2
  2988. 92b53fdfa7c4165b83dd2f8447f63928454a5815d08ff2d6165dd1a8969ecbe1 owncloud.tar.bz2
  2989. #+END_SRC
  2990. Extract the archive. This may take a couple of minutes, so don't be alarmed that the system has crashed.
  2991. #+BEGIN_SRC: bash
  2992. export HOSTNAME=mydomainname.com
  2993. tar -xjf owncloud.tar.bz2
  2994. #+END_SRC
  2995. Move the extracted files to your site and set file permissions.
  2996. #+BEGIN_SRC: bash
  2997. cp -r owncloud /var/www/$HOSTNAME/htdocs
  2998. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud/apps
  2999. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud/config
  3000. chown www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud
  3001. #+END_SRC
  3002. Edit the htaccess file for Owncloud.
  3003. #+BEGIN_SRC: bash
  3004. emacs /var/www/$HOSTNAME/htdocs/owncloud/.htaccess
  3005. #+END_SRC
  3006. Set the following.
  3007. #+BEGIN_SRC: bash
  3008. php_value upload_max_filesize 512M
  3009. php_value post_max_size 512M
  3010. php_value memory_limit 32M
  3011. #+END_SRC
  3012. Save and exit.
  3013. With a web browser visit your domain (mydomainname.com/owncloud) and enter an administrator username and password.
  3014. *** Owncloud on Android
  3015. 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.
  3016. ** Install a Wiki
  3017. #+BEGIN_VERSE
  3018. /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./
  3019. -- Tom Barbalet
  3020. #+END_VERSE
  3021. Dokuwiki is based upon flat files, and so is easy to move from one server to another without a lot of database complications.
  3022. Download the wiki.
  3023. #+BEGIN_SRC: bash
  3024. cd /tmp
  3025. wget http://freedombone.uk.to/dokuwiki.tgz
  3026. #+END_SRC
  3027. Verify it.
  3028. #+BEGIN_SRC: bash
  3029. sha256sum dokuwiki.tgz
  3030. 6b126f90979463d9ddaa74acc6f96aa230cfdc789946f241c3646086d9574be8 dokuwiki.tgz
  3031. #+END_SRC
  3032. Then extract and install it.
  3033. #+BEGIN_SRC: bash
  3034. export HOSTNAME=mywikidomainname.com
  3035. tar -xzvf dokuwiki.tgz
  3036. mv /var/www/$HOSTNAME/htdocs /var/www/$HOSTNAME/htdocs_old
  3037. mv dokuwiki /var/www/$HOSTNAME/htdocs
  3038. #+END_SRC
  3039. Edit the Apache configuration for your wiki site.
  3040. #+BEGIN_SRC: bash
  3041. emacs /etc/apache2/sites-available/$HOSTNAME
  3042. #+END_SRC
  3043. The settings should look something like the following. Replace /mywikidomainname.com/ with your wiki domain name.
  3044. #+BEGIN_SRC: bash
  3045. <VirtualHost *:80>
  3046. ServerAdmin myusername@mywikidomainname.com
  3047. ServerName mydomainname.com
  3048. DocumentRoot /var/www/mywikidomainname.com/htdocs
  3049. <Directory /var/www/mywikidomainname.com/htdocs>
  3050. order deny,allow
  3051. allow from all
  3052. </Directory>
  3053. <LocationMatch "/(data|conf|bin|inc)/">
  3054. order allow,deny
  3055. deny from all
  3056. satisfy all
  3057. </LocationMatch>
  3058. <Directory />
  3059. Options FollowSymLinks
  3060. AllowOverride All
  3061. </Directory>
  3062. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  3063. <Directory "/usr/lib/cgi-bin">
  3064. AllowOverride All
  3065. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  3066. Order allow,deny
  3067. Allow from all
  3068. </Directory>
  3069. ErrorLog ${APACHE_LOG_DIR}/error.log
  3070. # Possible values include: debug, info, notice, warn, error, crit,
  3071. # alert, emerg.
  3072. LogLevel error
  3073. CustomLog ${APACHE_LOG_DIR}/access.log combined
  3074. </VirtualHost>
  3075. <IfModule mod_ssl.c>
  3076. <VirtualHost *:443>
  3077. ServerAdmin myusername@mywikidomainname.com
  3078. ServerName mywikidomainname.com
  3079. DocumentRoot /var/www/mywikidomainname.com/htdocs
  3080. <Directory /var/www/mywikidomainname.com/htdocs>
  3081. order deny,allow
  3082. allow from all
  3083. </Directory>
  3084. <LocationMatch "/(data|conf|bin|inc)/">
  3085. order allow,deny
  3086. deny from all
  3087. satisfy all
  3088. </LocationMatch>
  3089. <Directory />
  3090. Options FollowSymLinks
  3091. AllowOverride All
  3092. </Directory>
  3093. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  3094. <Directory "/usr/lib/cgi-bin">
  3095. AllowOverride All
  3096. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  3097. Order allow,deny
  3098. Allow from all
  3099. </Directory>
  3100. ErrorLog ${APACHE_LOG_DIR}/error.log
  3101. # Possible values include: debug, info, notice, warn, error, crit,
  3102. # alert, emerg.
  3103. LogLevel error
  3104. CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
  3105. # SSL Engine Switch:
  3106. # Enable/Disable SSL for this virtual host.
  3107. SSLEngine on
  3108. # A self-signed certificate
  3109. SSLCertificateFile /etc/ssl/certs/mydomainname.com.crt
  3110. SSLCertificateKeyFile /etc/ssl/private/mydomainname.com.key
  3111. # Options based on bettercrypto.org
  3112. SSLProtocol All -SSLv2 -SSLv3
  3113. SSLHonorCipherOrder On
  3114. SSLCompression off
  3115. 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
  3116. # SSL Engine Options:
  3117. # Set various options for the SSL engine.
  3118. # o FakeBasicAuth:
  3119. # Translate the client X.509 into a Basic Authorisation. This means that
  3120. # the standard Auth/DBMAuth methods can be used for access control. The
  3121. # user name is the `one line' version of the client's X.509 certificate.
  3122. # Note that no password is obtained from the user. Every entry in the user
  3123. # file needs this password: `xxj31ZMTZzkVA'.
  3124. # o ExportCertData:
  3125. # This exports two additional environment variables: SSL_CLIENT_CERT and
  3126. # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
  3127. # server (always existing) and the client (only existing when client
  3128. # authentication is used). This can be used to import the certificates
  3129. # into CGI scripts.
  3130. # o StdEnvVars:
  3131. # This exports the standard SSL/TLS related `SSL_*' environment variables.
  3132. # Per default this exportation is switched off for performance reasons,
  3133. # because the extraction step is an expensive operation and is usually
  3134. # useless for serving static content. So one usually enables the
  3135. # exportation for CGI and SSI requests only.
  3136. # o StrictRequire:
  3137. # This denies access when "SSLRequireSSL" or "SSLRequire" applied even
  3138. # under a "Satisfy any" situation, i.e. when it applies access is denied
  3139. # and no other module can change it.
  3140. # o OptRenegotiate:
  3141. # This enables optimized SSL connection renegotiation handling when SSL
  3142. # directives are used in per-directory context.
  3143. #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
  3144. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  3145. SSLOptions +StdEnvVars
  3146. </FilesMatch>
  3147. <Directory /usr/lib/cgi-bin>
  3148. SSLOptions +StdEnvVars
  3149. </Directory>
  3150. # SSL Protocol Adjustments:
  3151. # The safe and default but still SSL/TLS standard compliant shutdown
  3152. # approach is that mod_ssl sends the close notify alert but doesn't wait for
  3153. # the close notify alert from client. When you need a different shutdown
  3154. # approach you can use one of the following variables:
  3155. # o ssl-unclean-shutdown:
  3156. # This forces an unclean shutdown when the connection is closed, i.e. no
  3157. # SSL close notify alert is send or allowed to received. This violates
  3158. # the SSL/TLS standard but is needed for some brain-dead browsers. Use
  3159. # this when you receive I/O errors because of the standard approach where
  3160. # mod_ssl sends the close notify alert.
  3161. # o ssl-accurate-shutdown:
  3162. # This forces an accurate shutdown when the connection is closed, i.e. a
  3163. # SSL close notify alert is send and mod_ssl waits for the close notify
  3164. # alert of the client. This is 100% SSL/TLS standard compliant, but in
  3165. # practice often causes hanging connections with brain-dead browsers. Use
  3166. # this only for browsers where you know that their SSL implementation
  3167. # works correctly.
  3168. # Notice: Most problems of broken clients are also related to the HTTP
  3169. # keep-alive facility, so you usually additionally want to disable
  3170. # keep-alive for those clients, too. Use variable "nokeepalive" for this.
  3171. # Similarly, one has to force some clients to use HTTP/1.0 to workaround
  3172. # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
  3173. # "force-response-1.0" for this.
  3174. BrowserMatch "MSIE [2-6]" \
  3175. nokeepalive ssl-unclean-shutdown \
  3176. downgrade-1.0 force-response-1.0
  3177. # MSIE 7 and newer should be able to use keepalive
  3178. BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  3179. </VirtualHost>
  3180. </IfModule>
  3181. #+END_SRC
  3182. Enable your site with:
  3183. #+BEGIN_SRC: bash
  3184. a2ensite
  3185. #+END_SRC
  3186. then select the domain name and reload.
  3187. #+BEGIN_SRC: bash
  3188. service apache2 reload
  3189. #+END_SRC
  3190. and alter permissions:
  3191. #+BEGIN_SRC: bash
  3192. chmod -R 755 /var/www/$HOSTNAME/htdocs
  3193. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs
  3194. #+END_SRC
  3195. Open a browser and visit http://$HOSTNAME/install.php, then fill out the details. Once everything has been accepted without errors:
  3196. #+BEGIN_SRC: bash
  3197. rm /var/www/$HOSTNAME/htdocs/install.php
  3198. #+END_SRC
  3199. Add a few extra mime types:
  3200. #+BEGIN_SRC: bash
  3201. emacs /var/www/$HOSTNAME/htdocs/conf/mime.conf
  3202. #+END_SRC
  3203. Append the following:
  3204. #+BEGIN_SRC: bash
  3205. ogv video/ogg
  3206. mp4 video/mp4
  3207. webm video/webm
  3208. #+END_SRC
  3209. Save and exit.
  3210. 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*.
  3211. Now you can visit your wiki and begin editing.
  3212. ** Install Bitmessage
  3213. #+BEGIN_VERSE
  3214. /The weakness of mass surveillance is that it can very easily be made much more expensive through changes in technical standards: pervasive, end-to-end encryption can quickly make indiscriminate surveillance impossible on a cost-effective basis/
  3215. -- Edward J. Snowden, testimony to the EU parliament
  3216. #+END_VERSE
  3217. *** A new kind of Email
  3218. [[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.
  3219. 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.
  3220. Installing Bitmessage as a daemon will increase the size of the network, and therefore the level of security for all users.
  3221. *** The Daemon
  3222. Install from the current source code.
  3223. #+BEGIN_SRC: bash
  3224. apt-get install python screen
  3225. cd /tmp
  3226. git clone https://github.com/Bitmessage/PyBitmessage.git
  3227. cd PyBitmessage
  3228. make install
  3229. #+END_SRC
  3230. Now create the daemon.
  3231. #+BEGIN_SRC: bash
  3232. emacs /etc/init.d/pybitmessage
  3233. #+END_SRC
  3234. Add the following text:
  3235. #+BEGIN_SRC: bash
  3236. #!/bin/bash
  3237. # /etc/init.d/bitmessage
  3238. ### BEGIN INIT INFO
  3239. # Provides: pybitmessage
  3240. # Required-Start: $remote_fs $syslog
  3241. # Required-Stop: $remote_fs $syslog
  3242. # Default-Start: 2 3 4 5
  3243. # Default-Stop: 0 1 6
  3244. # Short-Description: starts bitmessage as a background daemon, suitable for servers
  3245. # Description: This file should be used to construct scripts to be
  3246. # placed in /etc/init.d.
  3247. ### END INIT INFO
  3248. # Author: Super-Nathan <BM-Gu2k3Wy2hpTMYBxSoM2937SPcuU6xzEj>
  3249. #Settings
  3250. SERVICE='pybitmessage'
  3251. LOGFILE='/dev/null' # this disables logging
  3252. # LOGFILE='/var/log/bitmessage.log' # comment out the above line and un-comment this line to save a log
  3253. COMMAND="python bitmessagemain.py > $LOGFILE"
  3254. USERNAME='bitmsg'
  3255. NICELEVEL=19 # from 0-19 the bigger the number, the less the impact on system resources
  3256. HISTORY=1024
  3257. PBM_LOCATION="/usr/local/share/pybitmessage"
  3258. INVOCATION="nice -n ${NICELEVEL} ${COMMAND}"
  3259. PATH='/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl:/sbin:/usr/sbin:/bin:/usr/local/share/pybitmessage'
  3260. bm_start() {
  3261. echo "Starting $SERVICE..."
  3262. cd ${PBM_LOCATION}
  3263. su --command "screen -h ${HISTORY} -dmS ${SERVICE} ${INVOCATION}" $USERNAME
  3264. }
  3265. bm_stop() {
  3266. echo "Stopping $SERVICE"
  3267. su --command "screen -p 0 -S ${SERVICE} -X stuff "'^C'"" $USERNAME
  3268. }
  3269. #Start-Stop here
  3270. case "$1" in
  3271. start)
  3272. bm_start
  3273. ;;
  3274. stop)
  3275. bm_stop
  3276. ;;
  3277. restart)
  3278. bm_stop
  3279. sleep 60s
  3280. bm_start
  3281. ;;
  3282. *)
  3283. echo "Usage: $0 {start|stop|restart}"
  3284. exit 1
  3285. ;;
  3286. esac
  3287. exit 0
  3288. #+END_SRC
  3289. Save and exit.
  3290. 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.
  3291. #+BEGIN_SRC: bash
  3292. adduser bitmsg
  3293. #+END_SRC
  3294. Create a /keys.dat/ file which is used to configure Bitmessage.
  3295. #+BEGIN_SRC: bash
  3296. mkdir /home/bitmsg/.config
  3297. mkdir /home/bitmsg/.config/PyBitmessage
  3298. emacs /home/bitmsg/.config/PyBitmessage/keys.dat
  3299. #+END_SRC
  3300. Add the following:
  3301. #+BEGIN_SRC: bash
  3302. [bitmessagesettings]
  3303. settingsversion = 7
  3304. port = 8444
  3305. timeformat = %%a, %%d %%b %%Y %%I:%%M %%p
  3306. blackwhitelist = black
  3307. startonlogon = false
  3308. minimizetotray = false
  3309. showtraynotifications = false
  3310. startintray = false
  3311. socksproxytype = none
  3312. sockshostname = localhost
  3313. socksport = 9050
  3314. socksauthentication = false
  3315. sockslisten = false
  3316. socksusername =
  3317. sockspassword =
  3318. keysencrypted = false
  3319. messagesencrypted = false
  3320. defaultnoncetrialsperbyte = 640
  3321. defaultpayloadlengthextrabytes = 14000
  3322. minimizeonclose = false
  3323. maxacceptablenoncetrialsperbyte = 0
  3324. maxacceptablepayloadlengthextrabytes = 0
  3325. userlocale = system
  3326. namecoinrpctype = namecoind
  3327. namecoinrpchost = localhost
  3328. namecoinrpcuser =
  3329. namecoinrpcpassword =
  3330. namecoinrpcport = 8336
  3331. sendoutgoingconnections = True
  3332. daemon = true
  3333. #+END_SRC
  3334. Save and exit. Then enable the daemon and run it.
  3335. #+BEGIN_SRC: bash
  3336. rm -f /tmp/-usr-local-share-pybitmessage-*.lock
  3337. chown -R bitmsg:bitmsg /home/bitmsg
  3338. chmod +x /etc/init.d/pybitmessage
  3339. update-rc.d pybitmessage defaults
  3340. service pybitmessage start
  3341. #+END_SRC
  3342. Now open port 8444 on your internet router or firewall and direct it to the BBB.
  3343. *** Using Bitmessage
  3344. 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.
  3345. 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:
  3346. #+BEGIN_SRC: bash
  3347. cd /tmp
  3348. git clone https://github.com/Bitmessage/PyBitmessage.git
  3349. cd PyBitmessage
  3350. make install
  3351. pybitmessage
  3352. #+END_SRC
  3353. *** Connect to Email
  3354. TODO: how to connect Bitmessage to an email client.
  3355. #+BEGIN_SRC: bash
  3356. cd /tmp
  3357. wget http://freedombone.uk.to/notbit.tar.gz
  3358. #+END_SRC
  3359. Verify it.
  3360. #+BEGIN_SRC: bash
  3361. sha256sum notbit.tar.gz
  3362. 972fdc9cbb8034141282337dcd5e557bce57969ff6bd1d607da89bd93cc7bb68
  3363. #+END_SRC
  3364. Extract and install it.
  3365. #+BEGIN_SRC: bash
  3366. tar -xzvf notbit.tar.gz
  3367. cd notbit
  3368. apt-get install dh-autoreconf
  3369. ./autogen.sh --prefix=/home/myusername
  3370. make
  3371. make install
  3372. #+END_SRC
  3373. ** Overcome restrictive environments
  3374. #+BEGIN_VERSE
  3375. /Censorship reflects a society's lack of confidence in itself. It is a hallmark of an authoritarian regime./
  3376. -- Potter Stewart
  3377. #+END_VERSE
  3378. 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.
  3379. 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.
  3380. #+BEGIN_SRC: bash
  3381. apt-get install shellinabox libapache2-mod-proxy-html
  3382. #+END_SRC
  3383. Update your Apache configuration.
  3384. #+BEGIN_SRC: bash
  3385. export HOSTNAME=mydomainname.com
  3386. emacs /etc/apache2/sites-available/$HOSTNAME
  3387. #+END_SRC
  3388. Within the section which begins with *<VirtualHost *:443>* add the following, replacing /mydomainname.com/ with your domain name and /myusername/ with your username.
  3389. #+BEGIN_SRC: bash
  3390. <Location /shell>
  3391. ProxyPass http://localhost:4200/
  3392. Order allow,deny
  3393. Allow from all
  3394. AuthName "Authentication for shellinabox"
  3395. AuthUserFile /home/mydomainname.com/public_html/.htpasswd
  3396. AuthGroupFile /home/mydomainname.com/public_html/.htgroup
  3397. AuthType Basic
  3398. Require group shellinabox
  3399. Require user myusername
  3400. </Location>
  3401. #+END_SRC
  3402. 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.
  3403. #+BEGIN_SRC: bash
  3404. mkdir /home/$HOSTNAME
  3405. mkdir /home/$HOSTNAME/public_html
  3406. htpasswd -c /home/$HOSTNAME/public_html/.htpasswd myusername
  3407. #+END_SRC
  3408. Create a user group.
  3409. #+BEGIN_SRC: bash
  3410. emacs /home/$HOSTNAME/public_html/.htgroup
  3411. #+END_SRC
  3412. Add the following:
  3413. #+BEGIN_SRC: bash
  3414. shellinabox: myusername
  3415. #+END_SRC
  3416. Save and exit, then restart Apache.
  3417. #+BEGIN_SRC: bash
  3418. a2enmod proxy_http
  3419. service apache2 restart
  3420. #+END_SRC
  3421. Now with a web browser navigate to https://mydomainname.com/shell and log in.
  3422. 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/.
  3423. ** Set up a mailing list
  3424. #+BEGIN_VERSE
  3425. /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./
  3426. -- Jono Bacon
  3427. #+END_VERSE
  3428. *** Public mailing list
  3429. Email mailing lists are old skool but still remain as a common and easy way of communicating on the internet. If you're running a public organisation such as an open source project or community group then you may want to set one up.
  3430. **** Installation
  3431. #+BEGIN_SRC: bash
  3432. export HOSTNAME=mydomainname.com
  3433. apt-get install mailman
  3434. newlist mailman
  3435. #+END_SRC
  3436. Enter an email address for the list administrator and a password.
  3437. #+BEGIN_SRC: bash
  3438. emacs /etc/mailman/mm_cfg.py
  3439. #+END_SRC
  3440. Set *MTA=None* and change *http:* to *https:*, then save and exit.
  3441. Add some settings.
  3442. #+BEGIN_SRC: bash
  3443. emacs /etc/exim4/conf.d/main/04_mailman_options
  3444. #+END_SRC
  3445. Add the following, replacing /mydomainname.com/ with your domain name.
  3446. #+BEGIN_SRC: bash
  3447. # Mailman macro definitions
  3448. # Home dir for the Mailman installation
  3449. MM_HOME=/var/lib/mailman
  3450. # User and group for Mailman
  3451. MM_UID=list
  3452. MM_GID=list
  3453. #
  3454. # Domains that your lists are in - colon separated list
  3455. # you may wish to add these into local_domains as well
  3456. domainlist mm_domains=mydomainname.com
  3457. # The path of the Mailman mail wrapper script
  3458. MM_WRAP=MM_HOME/mail/mailman
  3459. #
  3460. # The path of the list config file (used as a required file when
  3461. # verifying list addresses)
  3462. MM_LISTCHK=MM_HOME/lists/${lc::$local_part}/config.pck
  3463. #+END_SRC
  3464. Save and exit.
  3465. #+BEGIN_SRC: bash
  3466. emacs /etc/exim4/conf.d/main/000_localmacros
  3467. #+END_SRC
  3468. Append the following:
  3469. #+BEGIN_SRC: bash
  3470. SYSTEM_ALIASES_PIPE_TRANSPORT = address_pipe
  3471. SYSTEM_ALIASES_USER = list
  3472. SYSTEM_ALIASES_GROUP = list
  3473. #+END_SRC
  3474. Save and exit.
  3475. #+BEGIN_SRC: bash
  3476. emacs /etc/exim4/conf.d/acl/30_exim4-config_check_rcpt
  3477. #+END_SRC
  3478. Append the following, before the final /accept/:
  3479. #+BEGIN_SRC: bash
  3480. # Do callback verification unless Mailman incoming bounce
  3481. deny !local_parts = *-bounces : *-bounces+*
  3482. !verify = sender/callout=30s,defer_ok
  3483. #+END_SRC
  3484. Save and exit.
  3485. #+BEGIN_SRC: bash
  3486. emacs
  3487. /etc/exim4/conf.d/router/450_exim4-config_mailman_aliases
  3488. #+END_SRC
  3489. Add the following:
  3490. #+BEGIN_SRC: bash
  3491. mailman:
  3492. driver = accept
  3493. domains = +mm_domains
  3494. require_files = MM_LISTCHK
  3495. local_part_suffix_optional
  3496. local_part_suffix = -admin : \
  3497. -bounces : -bounces+* : \
  3498. -confirm : -confirm+* : \
  3499. -join : -leave : \
  3500. -owner : -request : \
  3501. -subscribe : -unsubscribe
  3502. transport = mailman_transport
  3503. #+END_SRC
  3504. Save and exit.
  3505. #+BEGIN_SRC: bash
  3506. emacs /etc/exim4/conf.d/transport/40_exim4-config_mailman_pipe
  3507. #+END_SRC
  3508. Add the following:
  3509. #+BEGIN_SRC: bash
  3510. mailman_transport:
  3511. driver = pipe
  3512. command = MM_WRAP \
  3513. '${if def:local_part_suffix \
  3514. {${sg{$local_part_suffix}{-(\\w+)(\\+.*)?}{\$1}}} \
  3515. {post}}' \
  3516. $local_part
  3517. current_directory = MM_HOME
  3518. home_directory = MM_HOME
  3519. user = MM_UID
  3520. group = MM_GID
  3521. #+END_SRC
  3522. Save and exit.
  3523. #+BEGIN_SRC: bash
  3524. chown root:list /var/lib/mailman/mail/mailman
  3525. update-exim4.conf.template -r
  3526. update-exim4.conf
  3527. service exim4 restart
  3528. emacs /etc/apache2/conf.d/mailman
  3529. #+END_SRC
  3530. Add the following:
  3531. #+BEGIN_SRC: bash
  3532. Alias /pipermail /var/lib/mailman/archives/public
  3533. Alias /images/mailman /usr/share/images/mailman
  3534. <directory /var/lib/mailman/archives/public>
  3535. DirectoryIndex index.html
  3536. </directory>
  3537. #+END_SRC
  3538. Save and exit.
  3539. #+BEGIN_SRC: bash
  3540. emacs /etc/apache2/sites-available/$HOSTNAME
  3541. #+END_SRC
  3542. Add the following to the 443 section.
  3543. #+BEGIN_SRC: bash
  3544. <Location /mailman>
  3545. Options Indexes FollowSymLinks MultiViews
  3546. Order allow,deny
  3547. Allow from all
  3548. RedirectMatch ^/$ /cgi-bin/mailman/listinfo
  3549. </Location>
  3550. #+END_SRC
  3551. Save and exit.
  3552. #+BEGIN_SRC: bash
  3553. service apache2 restart
  3554. #+END_SRC
  3555. Now add your mailing list. The list name should not include any spaces.
  3556. #+BEGIN_SRC: bash
  3557. newlist mymailinglistname
  3558. #+END_SRC
  3559. With a browser visit https://$HOSTNAME/cgi-bin/mailman/admin/mymailinglistname to configure the mailing list.
  3560. Under *General Options* add an email address for a moderator (could be the same as the administrator) and click *Submit your changes*.
  3561. Under *Privacy Options* set steps required for subscription to *Confirm and approve* and click *Submit your changes*.
  3562. Also change these settings for the account within https://$HOSTNAME/cgi-bin/mailman/admin/mailman
  3563. Then to test that the mailing list works:
  3564. #+BEGIN_SRC: bash
  3565. exim -d+route -bt mymailinglistname@$HOSTNAME
  3566. #+END_SRC
  3567. If everything is working then this shouldn't show any problems.
  3568. **** Using the mailing list
  3569. Direct subscribers towards:
  3570. #+BEGIN_SRC: bash
  3571. https://mydomainname.com/cgi-bin/mailman/listinfo/mymailinglistname
  3572. #+END_SRC
  3573. To administrate the list visit:
  3574. #+BEGIN_SRC: bash
  3575. https://mydomainname.com/cgi-bin/mailman/admin/mymailinglistname
  3576. #+END_SRC
  3577. To add another mailing list:
  3578. #+BEGIN_SRC: bash
  3579. newlist mymailinglistname
  3580. #+END_SRC
  3581. To delete a mailing list:
  3582. #+BEGIN_SRC: bash
  3583. rmlist -a mymailinglistname
  3584. #+END_SRC
  3585. *** Private (encrypted) mailing list
  3586. In addition to conventional public email lists it's also possible to set up a private mailing list which is only readable by members. A private email list uses [[https://en.wikipedia.org/wiki/GNU_Privacy_Guard][GPG]] and a public/private key pair for the server which can then be used to send emails to the list in an encrypted form. The email addresses and public GPG keys of members may be added to the list so that any new messages can be distributed to them in a secure manner.
  3587. Private mailing lists are likely to be able to keep the contents of the discussion out of the clutches of warrantless mass surveillance but, as with all conventional email, it won't prevent such systems from generating social graphs of who is communicating with the list since the /from/ and /to/ attributes are always transmitted in the clear.
  3588. **** Installation
  3589. #+BEGIN_SRC: bash
  3590. apt-get install schleuder
  3591. #+END_SRC
  3592. Edit the configuration:
  3593. #+BEGIN_SRC: bash
  3594. emacs /etc/schleuder/schleuder.conf
  3595. #+END_SRC
  3596. Set the following parameters, replacing /mydomainname.com/ with your domain name:
  3597. #+BEGIN_SRC: bash
  3598. smtp_port: 465
  3599. superadminaddr: root@mydomainname.com
  3600. #+END_SRC
  3601. Save and exit.
  3602. Get your GPG public key, replacing /myGPGkeyID/ with your GPG key ID:
  3603. #+BEGIN_SRC: bash
  3604. export MYKEYID=myGPGkeyID
  3605. gpg --search-keys $MYKEYID
  3606. gpg --output /tmp/mypublickey.txt --armor --export $MYKEYID
  3607. #+END_SRC
  3608. Then to create a mailing list, replacing /mydomainname.com/ with your domain name, /myusername/ with your username and /mailinglistname/ with the name of the mailing list. /mailinglistname/ should be all one word, with no spaces.
  3609. #+BEGIN_SRC: bash
  3610. export MAILINGLISTNAME=mailinglistname
  3611. export MYUSERNAME=myusername
  3612. export HOSTNAME=mydomainname.com
  3613. export EMAILADDRESS=$MYUSERNAME@$HOSTNAME
  3614. schleuder-newlist $MAILINGLISTNAME@$HOSTNAME -realname "mailing list name" -adminaddress $EMAILADDRESS -initmember $EMAILADDRESS -initmemberkey /tmp/mypublickey.txt -nointeractive
  3615. #+END_SRC
  3616. Now add a mailing list rule:
  3617. #+BEGIN_SRC: bash
  3618. emailrule $MYUSERNAME $MAILINGLISTNAME@$HOSTNAME $MAILINGLISTNAME
  3619. #+END_SRC
  3620. Edit your Mutt configuration.
  3621. #+BEGIN_SRC: bash
  3622. emacs /home/$MYUSERNAME/.muttrc
  3623. #+END_SRC
  3624. Search for the /mailboxes/ parameter and add "=mailinglistname". For example:
  3625. #+BEGIN_SRC: bash
  3626. mailboxes = =Sent =Drafts =mailinglistname
  3627. #+END_SRC
  3628. Save and exit.
  3629. Update Exim routing.
  3630. #+BEGIN_SRC: bash
  3631. emacs /etc/exim4/conf.d/router/550_exim4-config_schleuder
  3632. #+END_SRC
  3633. Add the following:
  3634. #+BEGIN_SRC: bash
  3635. schleuder:
  3636. debug_print = "R: schleuder for $local_part@$domain"
  3637. driver = accept
  3638. local_part_suffix_optional
  3639. local_part_suffix = +* : -bounce : -sendkey
  3640. domains = +local_domains
  3641. user = schleuder
  3642. group = schleuder
  3643. require_files = schleuder:+/var/lib/schleuder/$domain/${local_part}
  3644. transport = schleuder_transport
  3645. #+END_SRC
  3646. Save and exit.
  3647. #+BEGIN_SRC: bash
  3648. emacs /etc/exim4/conf.d/transport/30_exim4-config_schleuder
  3649. #+END_SRC
  3650. Add the following.
  3651. #+BEGIN_SRC: bash
  3652. schleuder_transport:
  3653. debug_print = "T: schleuder_transport for $local_part@$domain"
  3654. driver = pipe
  3655. home_directory = "/var/lib/schleuder/$domain/$local_part"
  3656. command = "/usr/bin/schleuder $local_part@$domain"
  3657. #+END_SRC
  3658. Save and exit.
  3659. #+BEGIN_SRC: bash
  3660. chown -R schleuder:schleuder /var/lib/schleuder
  3661. update-exim4.conf.template -r
  3662. update-exim4.conf
  3663. service exim4 restart
  3664. useradd -d /var/schleuderlists -s /bin/false schleuder
  3665. adduser Debian-exim schleuder
  3666. usermod -a -G mail schleuder
  3667. #+END_SRC
  3668. Test the routing.
  3669. #+BEGIN_SRC: bash
  3670. exim -d -bt mailinglistname@mydomainname.com
  3671. #+END_SRC
  3672. **** Importing the public key of the mailing list
  3673. Before you can use the mailing list you will first need to import its public key. How you do this depends upon which email client you're using.
  3674. ***** Using Mutt
  3675. Send an email to /mailinglistname-sendkey@mydomainname.com/ to have the list public key emailed to you.
  3676. When you receive the email open it and press *CTRL-k* to import it.
  3677. ***** Using Thunderbird
  3678. Send an email to /mailinglistname-sendkey@mydomainname.com/ to have the list public key emailed to you.
  3679. When you receive the email open it, select all the text with *CTRL-a* then *CTRL-c*.
  3680. On the menu select *OpenPGP* followed by *Key Management*.
  3681. You will now see a new menu bar. Select *Edit* followed by *Import keys from clipboard*.
  3682. Click on *Import* followed by *Ok*.
  3683. **** Using the list
  3684. To obtain the public keys of list members send an email to /mailinglistname-request@mydomainname.com/ containing *X-LIST-KEYS* in the message body.
  3685. To add a member: *X-ADD-MEMBER: othermember@otherdomain.net*
  3686. An example of adding a public key to the list:
  3687. #+BEGIN_SRC: bash
  3688. X-ADD-KEY:
  3689. -----BEGIN PGP PUBLIC KEY BLOCK-----
  3690. Version: GnuPG v1.4.9 (GNU/Linux)
  3691. mQGiBEjVO7oRBADQvT6wtD2IzzIiK0NbrcilCKCp4MWb8cYXTXguwPQI6y0Nerz4
  3692. dsK6J0X1Vgeo02tqA4xd3EDK8rdqL2yZfl/2egH8+85R3gDk+kqkfEp4pwCgp6VO
  3693. [...]
  3694. pNlF/qkaWwRb048h+iMrW21EkouLKTDPFkdFbapV2X5KJZIcfhO1zEbwc1ZKF3Ju
  3695. Q9X5GRmY62hz9SCZnsC0jeYAni8OUQV9NXfXlS/vePBUnOL08NQB
  3696. =xTv3
  3697. -----END PGP PUBLIC KEY BLOCK-----
  3698. #+END_SRC
  3699. To get details for a member: *X-GET-MEMBER: othermember@otherdomain.net*
  3700. To delete a member: *X-DELETE-MEMBER: othermember@otherdomain.net*
  3701. To delete a public key: *X-DELETE-KEY: keyID*
  3702. You can unsubscribe from the list with *X-UNSUBSCRIBE* in the message body.
  3703. *** Decentralised mailing list
  3704. A disadvantage with encrypted mailing lists which use the conventional email system is that there is a single server on which the list resides, and this creates a single point of failure and a bandwidth bottleneck for more heavily subscribed lists. If the mailing list server goes down for whatever reason then that may cause a lot of disruption to its users.
  3705. An alternative is to use a decentralised mailing list, implemented using Bitmessage. On your local machine (not the BBB) you can make a private mailing list which is difficult to censor and where there is no single point of failure. This type of mailing list is known as a "/chan/".
  3706. With Bitmessage if any one computer goes offline then the conversation can still keep going since there is no central mailing list server. Bitmessages are also encrypted with public/private key pairs and the manner in which the system operates makes it very difficult for the surveillance apparatus to exfiltrate the social graph of list users.
  3707. On a Debian based system:
  3708. #+BEGIN_SRC: bash
  3709. sudo apt-get install makepasswd
  3710. #+END_SRC
  3711. or on an RPM based system:
  3712. #+BEGIN_SRC: bash
  3713. sudo yum install makepasswd
  3714. #+END_SRC
  3715. Create a name for your mailing list. This will be a random string.
  3716. #+BEGIN_SRC: bash
  3717. makepasswd -c 40
  3718. #+END_SRC
  3719. Keep a note of this.
  3720. Run the Bitmessage client and on the menu select *File/Join-Create Chan/Create new chan*
  3721. Enter the random string which you created as the name of the mailing list. Also take a note of the BM address which is created.
  3722. You can hand out the random string used to generate the mailing list and its corresponding BM address to fellow members, either within a bitmessage or on paper or via [[https://en.wikipedia.org/wiki/Sneakernet][sneakernet]] or in a GPG/PGP encrypted email or via an XMPP+OTR or Friendica private message. Once others have those two pieces of data then they will be able to join.
  3723. To make the list easier to identify, rather than just appearing as a random string, then under the *Your Identities* tab right click on it and select *Set Avatar* and assign a suitable icon.
  3724. The disadvantage of this type of mailing list is that it's not possible for any one participant to act as a list moderator, or in other words each participant must do their own moderation. That's ok if the size of the group is small, but if it's larger then anyone spamming or trolling the list can make things miserable for the others.
  3725. ** Install Tripwire
  3726. #+BEGIN_VERSE
  3727. /...by the time you get done with all of that, we have a freedom box/
  3728. -- Eben Moglen
  3729. #+END_VERSE
  3730. 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.
  3731. #+BEGIN_SRC: bash
  3732. apt-get install tripwire
  3733. export HOSTNAME=mydomainname.com
  3734. cd /etc/tripwire
  3735. cp arm-local.key $HOSTNAME-local.key
  3736. cp site.key $HOSTNAME-site.key
  3737. tripwire --init
  3738. tripwire --update-policy --secure-mode low /etc/tripwire/twpol.txt
  3739. tripwire --check --interactive
  3740. #+END_SRC
  3741. you will be asked for two passphrases ("site" and "local"). Make a note of these.
  3742. Turn off reporting of changes to system logs.
  3743. #+BEGIN_SRC: bash
  3744. emacs /etc/tripwire/twcfg.txt
  3745. #+END_SRC
  3746. Set *SYSLOGREPORTING* to false and comment out the line, then save and exit.
  3747. #+BEGIN_SRC: bash
  3748. emacs /etc/tripwire/twpol.txt
  3749. #+END_SRC
  3750. Comment out the line:
  3751. #+BEGIN_SRC: bash
  3752. /var/log -> $(SEC_CONFIG) ;
  3753. #+END_SRC
  3754. Then save and exit.
  3755. If you subsequently install any more packages or make configuration changes then update the policy again with:
  3756. #+BEGIN_SRC: bash
  3757. tripwire --update-policy --secure-mode low /etc/tripwire/twpol.txt
  3758. #+END_SRC
  3759. Also, to look for any rootkits.
  3760. #+BEGIN_SRC: bash
  3761. apt-get install rkhunter
  3762. #+END_SRC
  3763. * Router/Firewall ports
  3764. The following ports on your internet router/firewall should be forwarded to the BBB.
  3765. | Protocol | Port/s |
  3766. |---------------+------------|
  3767. | Gopher | 70 |
  3768. | HTTP | 80 |
  3769. | HTTPS | 443 |
  3770. | IMAP | 143 |
  3771. | IRC SSL | 6670 |
  3772. | SIP | 5060..5061 |
  3773. | SMTP | 25 |
  3774. | SMTPS | 465 |
  3775. | SSH | 22 |
  3776. | XMPP | 5222..5223 |
  3777. | XMPP (server) | 5269 |
  3778. | XMPP (BOSH) | 5280..5281 |
  3779. | Bitmessage | 8444 |
  3780. * Hints and Tips
  3781. ** Messaging security
  3782. 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.
  3783. ** Moving Domains
  3784. 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:
  3785. #+BEGIN_SRC: bash
  3786. find /var/www/mynewdomain/htdocs -type f -exec sed -i 's@myolddomain@mynewdomain@g' {} \;
  3787. #+END_SRC
  3788. If you're moving the blog to a new domain then you will need to delete the lock file:
  3789. #+BEGIN_SRC: bash
  3790. rm /var/www/myblogdomainname.com/htdocs/fp-content/%%setup.lock
  3791. #+END_SRC
  3792. Then visit your blog and reinstall it. Your existing content will be unaffected but you will need to delete the welcome post which gets added and also re-select your chosen theme.
  3793. ** MySql foo
  3794. *** Backup all databases
  3795. To back up all mysql databases:
  3796. #+BEGIN_SRC: bash
  3797. mysqldump -u root -p --all-databases --events > /var/backups/databasebackup.sql
  3798. #+END_SRC
  3799. *** Restoring a particular mysql database
  3800. To restore yesterday's friendica backup:
  3801. #+BEGIN_SRC: bash
  3802. mysql -D friendica -o < /var/backups/friendica_daily.sql
  3803. #+END_SRC
  3804. To restore yesterday's mediawiki backup:
  3805. #+BEGIN_SRC: bash
  3806. mysql -D wikidb -o < /var/backups/wikidb_daily.sql
  3807. #+END_SRC
  3808. *** Removing mysql server
  3809. If you manage to screw up sql server completely then it can be fully deleted with:
  3810. #+BEGIN_SRC: bash
  3811. ps aux | grep mysql
  3812. #+END_SRC
  3813. and use /kill -9 <pid>/ to kill all mysql processes.
  3814. #+BEGIN_SRC: bash
  3815. apt-get remove --purge mysql\*
  3816. apt-get clean
  3817. updatedb
  3818. #+END_SRC
  3819. * Deprecated
  3820. The following items have been deprecated until such time as a successful installation is achieved.
  3821. ** Collaborative Document Editing
  3822. #+BEGIN_VERSE
  3823. /Openness and participation are antidotes to surveillance and control./
  3824. -- Howard Rheingold
  3825. #+END_VERSE
  3826. #+BEGIN_SRC: bash
  3827. apt-get install nodejs-legacy
  3828. curl https://npmjs.org/install.sh | sh
  3829. #+END_SRC
  3830. Create an etherpad database.
  3831. #+BEGIN_SRC: bash
  3832. mysql -p
  3833. CREATE DATABASE etherpad CHARACTER SET utf8 COLLATE utf8_general_ci;
  3834. GRANT ALL PRIVILEGES ON etherpad.* TO etherpad@localhost IDENTIFIED BY '__yourPasswd__';
  3835. FLUSH PRIVILEGES;
  3836. exit
  3837. #+END_SRC
  3838. Download etherpad.
  3839. #+BEGIN_SRC: bash
  3840. export HOSTNAME=mydomainname.com
  3841. cd /var/www/$HOSTNAME/htdocs
  3842. git clone git://github.com/ether/etherpad-lite.git etherpad
  3843. #+END_SRC
  3844. Edit the configuration file
  3845. #+BEGIN_SRC: bash
  3846. cd /var/www/$HOSTNAME/htdocs/etherpad
  3847. cp settings.json.template settings.json
  3848. emacs /var/www/$HOSTNAME/htdocs/etherpad/settings.json
  3849. #+END_SRC
  3850. Change the following settings. /rAnD0m5tRIng/ should be altered to a random string 10 characters in length.
  3851. #+BEGIN_SRC: bash
  3852. //IP and port which etherpad should bind at
  3853. "ip": "127.0.0.1",
  3854. // set a session key
  3855. "sessionKey" : "rAnD0m5tRIng",
  3856. //configure the connection settings
  3857. "dbType" : "mysql",
  3858. "dbSettings" : {
  3859. "user" : "etherpad",
  3860. "host" : "localhost",
  3861. "password": "__yourPassword__",
  3862. "database": "etherpad"
  3863. },
  3864. // add admin user
  3865. "users": {
  3866. "admin": {
  3867. "password": "__yourAdminPassword__",
  3868. "is_admin": true
  3869. }
  3870. },
  3871. #+END_SRC
  3872. Save and exit, then create a system user.
  3873. #+BEGIN_SRC: bash
  3874. adduser --system --home=/var/www/$HOSTNAME/htdocs/etherpad/ --group etherpad
  3875. chown -R etherpad: /var/www/$HOSTNAME/htdocs/etherpad/
  3876. #+END_SRC
  3877. Create an init script using your favorite editor.
  3878. #+BEGIN_SRC: bash
  3879. emacs /etc/init.d/etherpad
  3880. #+END_SRC
  3881. Add the following, replacing /mydomainname.com/ with your domain name:
  3882. #+BEGIN_SRC: bash
  3883. #!/bin/sh
  3884. ### BEGIN INIT INFO
  3885. # Provides: etherpad-lite
  3886. # Required-Start: $local_fs $remote_fs $network $syslog
  3887. # Required-Stop: $local_fs $remote_fs $network $syslog
  3888. # Default-Start: 2 3 4 5
  3889. # Default-Stop: 0 1 6
  3890. # Short-Description: starts etherpad lite
  3891. # Description: starts etherpad lite using start-stop-daemon
  3892. ### END INIT INFO
  3893. PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin"
  3894. LOGFILE="/var/www/mydomainname.com/htdocs/etherpad/etherpad-lite.log"
  3895. EPLITE_DIR="/var/www/mydomainname.com/htdocs/etherpad"
  3896. EPLITE_BIN="bin/safeRun.sh"
  3897. USER="etherpad"
  3898. GROUP="etherpad"
  3899. DESC="Etherpad Lite"
  3900. NAME="etherpad-lite"
  3901. set -e
  3902. . /lib/lsb/init-functions
  3903. start() {
  3904. echo "Starting $DESC... "
  3905. start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile /var/run/$NAME.pid --exec $EPLITE_DIR/$EPLITE_BIN -- $LOGFILE || true
  3906. echo "done"
  3907. }
  3908. #We need this function to ensure the whole process tree will be killed
  3909. killtree() {
  3910. local _pid=$1
  3911. local _sig=${2-TERM}
  3912. for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
  3913. killtree ${_child} ${_sig}
  3914. done
  3915. kill -${_sig} ${_pid}
  3916. }
  3917. stop() {
  3918. echo "Stopping $DESC... "
  3919. while test -d /proc/$(cat /var/run/$NAME.pid); do
  3920. killtree $(cat /var/run/$NAME.pid) 15
  3921. sleep 0.5
  3922. done
  3923. rm /var/run/$NAME.pid
  3924. echo "done"
  3925. }
  3926. status() {
  3927. status_of_proc -p /var/run/$NAME.pid "" "etherpad-lite" && exit 0 || exit $?
  3928. }
  3929. case "$1" in
  3930. start)
  3931. start
  3932. ;;
  3933. stop)
  3934. stop
  3935. ;;
  3936. restart)
  3937. stop
  3938. start
  3939. ;;
  3940. status)
  3941. status
  3942. ;;
  3943. *)
  3944. echo "Usage: $NAME {start|stop|restart|status}" >&2
  3945. exit 1
  3946. ;;
  3947. esac
  3948. exit 0
  3949. #+END_SRC
  3950. Save and exit, then enable the daemon.
  3951. #+BEGIN_SRC: bash
  3952. chmod +x /etc/init.d/etherpad
  3953. update-rc.d etherpad defaults
  3954. service etherpad start
  3955. #+END_SRC
  3956. Update your Apache configuration.
  3957. #+BEGIN_SRC: bash
  3958. emacs /etc/apache2/sites-available/$HOSTNAME
  3959. #+END_SRC
  3960. Within the section which begins with *<VirtualHost *:443>* add the following:
  3961. #+BEGIN_SRC: bash
  3962. <Location /etherpad>
  3963. ProxyPass http://localhost:9001/
  3964. ProxyPassReverse http://localhost:9001/
  3965. Order allow,deny
  3966. allow from all
  3967. AuthName "Welcome to Etherpad"
  3968. AuthUserFile /home/mydomainname.com/public_html/.htpasswd
  3969. AuthGroupFile /home/mydomainname.com/public_html/.htgroup
  3970. AuthType Basic
  3971. Require group etherpad
  3972. </Location>
  3973. #+END_SRC
  3974. Save and exit, then restart Apache.
  3975. #+BEGIN_SRC: bash
  3976. apt-get install libapache2-mod-proxy-html
  3977. a2enmod proxy proxy_http headers deflate
  3978. service apache2 restart
  3979. #+END_SRC
  3980. Create some passwords for users.
  3981. #+BEGIN_SRC: bash
  3982. mkdir /home/$HOSTNAME
  3983. mkdir /home/$HOSTNAME/public_html
  3984. htpasswd -c /home/$HOSTNAME/public_html/.htpasswd myusername
  3985. #+END_SRC
  3986. Create a user group.
  3987. #+BEGIN_SRC: bash
  3988. emacs /home/$HOSTNAME/public_html/.htgroup
  3989. #+END_SRC
  3990. Add the following:
  3991. #+BEGIN_SRC: bash
  3992. etherpad: myusername
  3993. #+END_SRC
  3994. Save and exit.
  3995. ** Install a VoIP server
  3996. #+BEGIN_VERSE
  3997. /Our core principles, whether in software or sovereignty, have always been about freedom and dignity, for all people, on an equal basis/
  3998. -- David Sugar, GNU Telephony
  3999. #+END_VERSE
  4000. *** The server
  4001. 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.
  4002. Edit your package sources:
  4003. #+BEGIN_SRC: bash
  4004. emacs /etc/apt/sources.list
  4005. #+END_SRC
  4006. Append the following line:
  4007. #+BEGIN_SRC: bash
  4008. deb http://dev.gnutelephony.org/archive/ wheezy/
  4009. #+END_SRC
  4010. Save and exit.
  4011. 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
  4012. #+BEGIN_SRC: bash
  4013. apt-get install gnutelephony-keyring
  4014. #+END_SRC
  4015. After that it will be happy to accept it as a signed repository. The verification keys can also be directly fetched with
  4016. #+BEGIN_SRC: bash
  4017. cd /tmp
  4018. wget http://dev.gnutelephony.org/archive/wheezy/public.key
  4019. #+END_SRC
  4020. and manually added instead with
  4021. #+BEGIN_SRC: bash
  4022. apt-key add public.key
  4023. #+END_SRC
  4024. To make sure you have all dependencies, do
  4025. #+BEGIN_SRC: bash
  4026. apt-get update;apt-get dist-upgrade
  4027. #+END_SRC
  4028. Before we install anything, let's inspect what is available to us by using
  4029. #+BEGIN_SRC: bash
  4030. dpkg -l sipwitch
  4031. #+END_SRC
  4032. To see the main application. The columns will indicate if the package is installed, which version and a description of the package. Then do
  4033. #+BEGIN_SRC: bash
  4034. dpkg -l sipwitch-*
  4035. #+END_SRC
  4036. 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.
  4037. To install only the main application, do
  4038. #+BEGIN_SRC: bash
  4039. apt-get install sipwitch
  4040. #+END_SRC
  4041. and to install all supporting plugins:
  4042. #+BEGIN_SRC: bash
  4043. apt-get install sipwitch-plugin-scripting sipwitch-plugin-subscriber sipwitch-plugin-forward sipwitch-plugin-zeroconf
  4044. #+END_SRC
  4045. Add your user into the sipwitch group
  4046. #+BEGIN_SRC: bash
  4047. groupadd sipwitch
  4048. groupadd sipusers
  4049. usermod -aG sipwitch myusername
  4050. usermod -aG sipusers myusername
  4051. #+END_SRC
  4052. Then edit the configuration
  4053. #+BEGIN_SRC: bash
  4054. emacs /etc/sipwitch.conf
  4055. #+END_SRC
  4056. Change the *mapped* value from 200 to 20, since we don't want to be serving huge numbers of calls.
  4057. 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.
  4058. Do not set the *realm* value, as doing so seems to prevent the server from working.
  4059. Save and exit.
  4060. Create a digest string for your username:
  4061. #+BEGIN_SRC: bash
  4062. sipwitch digest myusername
  4063. #+END_SRC
  4064. Make a note of the resulting string because you're going to use it in the users file you'll now create.
  4065. #+BEGIN_SRC: bash
  4066. export HOSTNAME=mydomainname.com
  4067. touch /etc/sipwitch.d/$HOSTNAME.xml
  4068. chmod 600 /etc/sipwitch.d/$HOSTNAME.xml
  4069. emacs /etc/sipwitch.d/$HOSTNAME.xml
  4070. #+END_SRC
  4071. It should look something like the following:
  4072. #+BEGIN_SRC: bash
  4073. <provision>
  4074. <user id="myusername">
  4075. <digest>yourdigeststring</digest>
  4076. <extension>201</extension>
  4077. <display>Your full name</display>
  4078. </user>
  4079. </provision>
  4080. #+END_SRC
  4081. Save and exit. Now edit the configuration.
  4082. #+BEGIN_SRC: bash
  4083. emacs /etc/default/sipwitch
  4084. #+END_SRC
  4085. Change "desktop" to "server", then save and exit.
  4086. Update the IP settings:
  4087. #+BEGIN_SRC: bash
  4088. iptables -A INPUT -p tcp --dport 5060 -j ACCEPT
  4089. iptables -A INPUT -p udp --dport 5060 -j ACCEPT
  4090. iptables -A INPUT -p tcp --dport 5061 -j ACCEPT
  4091. iptables -A INPUT -p udp --dport 5061 -j ACCEPT
  4092. iptables-save
  4093. #+END_SRC
  4094. Test that it's working:
  4095. #+BEGIN_SRC: bash
  4096. pkill -9 sipw
  4097. sipw -x9 -f
  4098. #+END_SRC
  4099. 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.
  4100. #+BEGIN_SRC: bash
  4101. service sipwitch start
  4102. #+END_SRC
  4103. *** Clients
  4104. **** Jitsi
  4105. Download the latst version from https://jitsi.org/index.php/Main/Download
  4106. TODO
  4107. **** Twinkle client
  4108. The client should have a user profile as following:
  4109. The "user name" is the xxx id used in the <user id="xxx"> entry of /etc/sipwitch.conf
  4110. The "domain" is the yyy domain in the main config <stack><domain>yyy entry of /etc/sipwitch.conf
  4111. The SIP Authentication should have:
  4112. realm = realm as set in <registry><realm> of /etc/sipwitch.conf
  4113. authentication name = <user id="xx"> entry, same as "User Name" field.
  4114. password = value of <secret>zzz in <user> entry of /etc/sipwitch.conf
  4115. Under security tab, set "Enable ZRTP/SRTP encryption"
  4116. **** Android
  4117. TODO
  4118. CSipSimple?
  4119. ** Install Mediagoblin
  4120. #+BEGIN_SRC: bash
  4121. apt-get install git-core python python-dev python-lxml python-imaging python-virtualenv apache2-suexec libapache2-mod-fcgid
  4122. #+END_SRC
  4123. #+BEGIN_SRC: bash
  4124. adduser --system mediagoblin
  4125. addgroup mediagoblin
  4126. adduser mediagoblin mediagoblin
  4127. export HOSTNAME=mydomainname.com
  4128. cd /var/www/$HOSTNAME/htdocs
  4129. git clone git://gitorious.org/mediagoblin/mediagoblin.git mediagoblin
  4130. chown -hR mediagoblin:mediagoblin /var/www/$HOSTNAME/htdocs/mediagoblin
  4131. cd /var/www/$HOSTNAME/htdocs/mediagoblin
  4132. git submodule init && git submodule update
  4133. cp mediagoblin.ini mediagoblin_local.ini
  4134. emacs mediagoblin.ini
  4135. #+END_SRC
  4136. Set email_sender_address to the address you wish to be used as the sender for system-generated emails
  4137. Edit direct_remote_path, base_dir, and base_url if your mediagoblin directory is not the root directory of your vhost.
  4138. Save and exit.
  4139. #+BEGIN_SRC: bash
  4140. a2enmod suexec
  4141. a2enmod fcgid
  4142. emacs /etc/apache2/sites-available/$HOSTNAME
  4143. #+END_SRC
  4144. Add the following to the 80 virtual host, replacing mydomainname.com with your domain name.
  4145. #+BEGIN_SRC: bash
  4146. <Directory /var/www/mydomainname.com/htdocs/mediagoblin>
  4147. deny from all
  4148. </Directory>
  4149. #+END_SRC
  4150. Add the following to the 443 virtual host.
  4151. #+BEGIN_SRC: bash
  4152. # Serve static and media files via alias
  4153. Alias /mgoblin_static/ /var/www/mydomainname.com/htdocs/mediagoblin/mediagoblin/static/
  4154. Alias /mgoblin_media/ /var/www/mydomainname.com/htdocs/mediagoblin/user_dev/media/public/
  4155. # Rewrite all URLs to fcgi, except for static and media urls
  4156. RewriteEngine On
  4157. RewriteRule ^(mgoblin_static|mgoblin_media)($|/) - [L]
  4158. RewriteCond %{REQUEST_FILENAME} !-f
  4159. RewriteRule ^/(.*)$ /mg.fcgi/$1 [QSA,L]
  4160. # Allow access to static and media directories
  4161. <Directory /var/www/mydomainname.com/htdocs/mediagoblin/mediagoblin/static>
  4162. Order allow,deny
  4163. Allow from all
  4164. </Directory>
  4165. <Directory /var/www/mydomainname.com/htdocs/mediagoblin/mediagoblin/user_dev/media/public>
  4166. Order allow,deny
  4167. Allow from all
  4168. </Directory>
  4169. # Connect to fcgi server
  4170. FastCGIExternalServer /var/www/mg.fcgi -host 127.0.0.1:26543
  4171. #+END_SRC
  4172. Save and exit
  4173. #+BEGIN_SRC: bash
  4174. cd /var/www/$HOSTNAME/htdocs/mediagoblin
  4175. ./lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543
  4176. #+END_SRC
  4177. https://github.com/joar/mediagoblin-init-scripts
  4178. ** Kune
  4179. 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).
  4180. #+BEGIN_SRC: bash
  4181. apt-get install openjdk-6-jdk openjdk-7-jre mysql-server adduser dbconfig-common libjmagick6-jni
  4182. #+END_SRC
  4183. Add the Kune repository:
  4184. #+BEGIN_SRC: bash
  4185. emacs /etc/apt/sources.list
  4186. #+END_SRC
  4187. Append the following:
  4188. #+BEGIN_SRC: bash
  4189. deb ftp://ftp.kune.ourproject.org/pub/kune/debian/ stable/
  4190. #+END_SRC
  4191. Save and exit, then install the Kune package.
  4192. #+BEGIN_SRC: bash
  4193. gpg --keyserver pgp.mit.edu --recv-keys 9E358A05
  4194. gpg --armor --export 9E358A05 | apt-key add -
  4195. apt-get update
  4196. apt-get install kune
  4197. #+END_SRC
  4198. You will be asked for the MySql root password and another password to be used with the Kune database.
  4199. Allow the system to start automatically at boot.
  4200. #+BEGIN_SRC: bash
  4201. emacs /etc/default/kune
  4202. #+END_SRC
  4203. Set /START=yes/, then save and exit.
  4204. #+BEGIN_SRC: bash
  4205. service kune start
  4206. #+END_SRC
  4207. Now configure Apache.
  4208. #+BEGIN_SRC: bash
  4209. a2enmod expires
  4210. a2enmod proxy
  4211. a2enmod proxy_connect
  4212. a2enmod proxy_http
  4213. #+END_SRC
  4214. Upgrade the database.
  4215. #+BEGIN_SRC: bash
  4216. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.1.0+b5
  4217. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.1.0+b6
  4218. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.2.0+b12
  4219. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.2.0+b23
  4220. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.2.0+b25
  4221. #+END_SRC
  4222. Edit the Apache configuration.
  4223. #+BEGIN_SRC: bash
  4224. emacs /etc/apache2/sites-available/$HOSTNAME
  4225. #+END_SRC
  4226. <VirtualHost *:80>
  4227. ServerName YOURSERVERNAME
  4228. ProxyRequests Off
  4229. <Proxy *>
  4230. Order deny,allow
  4231. Allow from all
  4232. </Proxy>
  4233. <Files *.cache.*>
  4234. ExpiresActive On
  4235. ExpiresDefault "modification plus 2 years"
  4236. </Files>
  4237. <Files *.nocache.*>
  4238. ExpiresActive Off
  4239. </Files>
  4240. ProxyPass /kune/ http://localhost:8888/
  4241. ProxyPassReverse /kune/ http://localhost:8888/
  4242. <Location /var/www/mydomainname.com/htdocs/kune/>
  4243. Order allow,deny
  4244. Allow from all
  4245. </Location>
  4246. </VirtualHost>
  4247. Within a browser open https://mydomainname.com:8888
  4248. See documentation in /usr/share/doc/kune/INSTALL.gz
  4249. ** Add a Convergenge notary
  4250. Convergence is a secure replacement for the Certificate Authority System. Rather than employing a traditionally hard-coded list of immutable and largely untrusted CAs, Convergence allows you to configure a dynamic set of Notaries which use network perspective to validate your communication. For more details see [[http://convergence.io][convergence.io]]
  4251. #+BEGIN_SRC: bash
  4252. apt-get install python python-twisted-web python-twisted-names python-m2crypto python-openssl
  4253. cd /tmp
  4254. wget http://freedombone.uk.to/convergence-notary-current.tar.gz
  4255. #+END_SRC
  4256. Verify it:
  4257. #+BEGIN_SRC: bash
  4258. sha256sum convergence-notary-current.tar.gz
  4259. 6d3f7f30649c174c58ef4d719498d33737ddfa229f3d7fc51af0162b590d719b
  4260. #+END_SRC
  4261. Install it:
  4262. #+BEGIN_SRC: bash
  4263. tar zxvf convergence-notary-current.tar.gz
  4264. cd convergence-0.4
  4265. python ./setup.py install
  4266. #+END_SRC
  4267. Generate a key pair:
  4268. #+BEGIN_SRC: bash
  4269. convergence-gencert
  4270. #+END_SRC
  4271. When asked for a challenge password just hit *Enter* a couple of times. Then move the key pair to the appropriate directories as follows.
  4272. #+BEGIN_SRC: bash
  4273. mv mynotary.key /etc/ssl/private
  4274. chmod 400 /etc/ssl/private/mynotary.key
  4275. mv mynotary.pem /etc/ssl/certs
  4276. #+END_SRC
  4277. Now create the database:
  4278. #+BEGIN_SRC: bash
  4279. convergence-createdb
  4280. #+END_SRC
  4281. Create an initialisation script:
  4282. #+BEGIN_SRC: bash
  4283. convergence-notary -p 8432 -s 8433 -c /etc/ssl/certs/mynotary.pem -k /etc/ssl/private/mynotary.key
  4284. #+END_SRC
  4285. An initialisation script will be created automatically within /etc/init.d.
  4286. Generate a notary bundle:
  4287. #+BEGIN_SRC: bash
  4288. convergence-bundle
  4289. #+END_SRC
  4290. Enter your name, nickname, handle or whatever.
  4291. For the bundle location enter https://mydomainname.com/convergence.notary
  4292. For the Hostname press Enter.
  4293. #+BEGIN_SRC: bash
  4294. export HOSTNAME=mydomainname.com
  4295. mv mynotarybundle.notary /var/www/$HOSTNAME/htdocs/convergence.notary
  4296. chown www-data:www-data /var/www/$HOSTNAME/htdocs/convergence.notary
  4297. #+END_SRC
  4298. Now open ports 8432 and 8433 on your internet router or firewall and direct it to the BBB.
  4299. * Related projects
  4300. * [[https://freedomboxfoundation.org/][Freedombox]]
  4301. * [[https://arkos.io/][ArkOS]]