beaglebone.txt 195KB

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