beaglebone.txt 177KB

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