beaglebone.txt 225KB

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