beaglebone.txt 182KB

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