beaglebone.txt 232KB

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