beaglebone.txt 213KB

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