beaglebone.txt 237KB

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