beaglebone.txt 165KB

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