beaglebone.txt 184KB

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