beaglebone.txt 192KB

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