beaglebone.txt 184KB

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