beaglebone.txt 239KB

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