beaglebone.txt 219KB

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