beaglebone.txt 232KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234
  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
  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. [[./images/freedombone_small.jpg]]
  12. #+BEGIN_CENTER
  13. Copyright (C) 2014 Bob Mottram
  14. 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.
  15. 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/bashrc/freedombone][Github]].
  16. #+END_CENTER
  17. * Introduction
  18. #+BEGIN_VERSE
  19. /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./
  20. -- Edward J. Snowden
  21. #+END_VERSE
  22. ** What is FreedomBone?
  23. 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.
  24. 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.
  25. ** Do I need any prior knowledge?
  26. 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.
  27. ** Why should I do this?
  28. 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).
  29. 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. Especially if your activities include [[https://firstlook.org/theintercept/article/2014/03/20/inside-nsa-secret-efforts-hunt-hack-system-administrators/][systems administration]] or [[http://www.spiegel.de/international/germany/gchq-and-nsa-targeted-private-german-companies-a-961444.html][software engineering for any communications-related systems]] then it is highly likely that you have already been targeted and "tasked" by the surveillance apparatus.
  30. 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.
  31. ** After it's installed will it need a lot of maintenance?
  32. 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.
  33. ** Is it secure?
  34. Nothing is totally secure or infallible. You could have the most secure technology and yet still use easy to guess passwords. In general any software described as "uncrackable" or "guaranteed secure" is likely to be bogus and should be treated with suspicion. No matter what the hype may claim, all software has bugs so it's really a question of whether your communications are more secure or less secure. Using something like Freedombone will be likely to increase your degree of communications security to a level which is above average.
  35. This system will not defend you from an attacker who is actively trying to block or corrupt your communications, but I assume that doesn't apply in the majority of cases. Another thing to be aware of is that running a FreedomBone could make you more vulnerable to traffic analysis, since the server is associated with your home address and isn't a giant aggregation of users somewhere in the cloud. You need to weigh this alongside the additional legal protection which owning the server and having it in your own home gives you.
  36. FreedomBone should be far more secure than using popular cloud-based services which have spying built into them as a core feature (although not one which is typically advertised), but it is not necessarily any kind of impenetrable information fortress.
  37. This project is not only about security. It's also about having independence and at least in the realm of information being able to have more control over your own life, without having gatekeepers, censors or companies in the middle. That's the way that the internet was designed to be in the first place.
  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 that the surveillance apparatus has succeeded in keeping you under observation at all times.
  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/2A 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. One way to test whether the board has enough power is to try compiling a Linux kernel on it, but any CPU and disk intensive program will also suffice as a test.
  61. [[http://beagleboard.org/Support/FAQ][beagleboard.org]] gives the following advice on power supplies:
  62. #+BEGIN_VERSE
  63. /Power over USB is sufficient as long as the software and system running perform some management to keep it under the USB current limit threshold. For simplicity and maximum capability, powering over the 5V barrel connector is typically recommended./
  64. /The power adapter is required to provide 5V over a 5.5mm outer diameter and 2.1mm inner diameter barrel connector (a barrel connector length of 9.5mm is more than sufficient). The recommended supply current is at least 1.2A (or 6W), but at least 2A (or 10W) is recommended if you are going to connect up anything over the USB./
  65. #+END_VERSE
  66. The plug should be /centre positive/, meaning that the centre/tip is positive and the outer part is negative.
  67. ** An ethernet patch cable
  68. Just an ordinary cat5 or cat6 cable that you can get from most electrical/computer stores.
  69. * Installing Debian onto the microSD card
  70. ** Beaglebone Black
  71. 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.
  72. Download the image.
  73. #+BEGIN_SRC: bash
  74. cd ~/
  75. wget http://freedombone.uk.to/debian-7.2-console-armhf-2013-11-15.tar.xz
  76. #+END_SRC
  77. Verify it.
  78. #+BEGIN_SRC: bash
  79. sha256sum debian-7.2-console-armhf-2013-11-15.tar.xz
  80. 262ea96d6bff530ad545e001eb2aa50b26a999c02f0c0e2e5f8536edf21c973a debian-7.2-console-armhf-2013-11-15.tar.xz
  81. #+END_SRC
  82. Uncompress it.
  83. #+BEGIN_SRC: bash
  84. tar xJf debian-7.2-console-armhf-2013-11-15.tar.xz
  85. cd debian-7.2-console-armhf-2013-11-15
  86. #+END_SRC
  87. Create the disk image, where sdX is the name of the flash drive (probably it will be sdb or sdc). An easy way to find out the device name of the flash drive is to enter the command:
  88. #+BEGIN_SRC: bash
  89. ls /dev/sd*
  90. #+END_SRC
  91. then plug in the flash drive and type the same command again. You'll be able to see the difference. Once you know the device name then you can proceed to install the image onto the flash drive.
  92. #+BEGIN_SRC: bash
  93. sudo apt-get install u-boot-tools dosfstools git-core kpartx wget parted
  94. sudo ./setup_sdcard.sh --mmc /dev/sdX --uboot bone --swap-file 1024
  95. #+END_SRC
  96. Once completed then safely remove the microSD card via your file manager (usually right click and "safely remove" or "eject").
  97. ** Cubieboard
  98. 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.
  99. Download the Cubieboard image from http://cubian.org/downloads/
  100. #+BEGIN_SRC: bash
  101. sudo apt-get install p7zip-full
  102. 7z x CUBIAN_IMAGE.7z
  103. #+END_SRC
  104. Create the disk image, where sdX is the name of the flash drive (probably it will be sdb or sdc). An easy way to find out the device name of the flash drive is to enter the command:
  105. #+BEGIN_SRC: bash
  106. ls /dev/sd*
  107. #+END_SRC
  108. then plug in the flash drive and type the same command again. You'll be able to see the difference. Once you know the device name then you can proceed to install the image onto the flash drive.
  109. #+BEGIN_SRC: bash
  110. sudo dd if=EXTRACTED_CUBIAN_IMAGE of=/dev/sdX bs=4096; sync
  111. #+END_SRC
  112. * Setup
  113. #+BEGIN_VERSE
  114. /Build the tools for a future you would want to live in/
  115. -- Kurt Opsahl
  116. #+END_VERSE
  117. ** Things to be aware of
  118. *** A note on ssh
  119. 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:
  120. #+BEGIN_SRC: bash
  121. ssh-keygen -R <IP address>
  122. #+END_SRC
  123. *** Passwords
  124. 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.
  125. *** HTTPS
  126. 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..
  127. 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.
  128. ** Initial
  129. Eject the microSD card from your computer and plug it into the BBB, then connect the USB cable between the two. You may need to wait for a couple of minutes for the BBB to boot from the card, then you can then open a terminal and login via ssh.
  130. Note that if you're using a Cubieboard then the ssh login is different (see https://github.com/cubieplayer/Cubian/wiki/Get-started-with-Cubian) and it may be easier to directly edit the following files with the microSD card plugged into your laptop.
  131. #+BEGIN_SRC: bash
  132. ssh debian@192.168.7.2
  133. #+END_SRC
  134. The default password is /temppwd/
  135. Then log in as root:
  136. #+BEGIN_SRC: bash
  137. su
  138. #+END_SRC
  139. The default password is /root/
  140. The first thing to do is to change the passwords from their defaults.
  141. #+BEGIN_SRC: bash
  142. passwd
  143. #+END_SRC
  144. 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.
  145. #+BEGIN_SRC: bash
  146. nano /etc/network/interfaces
  147. #+END_SRC
  148. The resulting interfaces file should look like this:
  149. #+BEGIN_SRC: bash
  150. # This file describes the network interfaces available on your system
  151. # and how to activate them. For more information, see interfaces(5).
  152. # The loopback network interface
  153. auto lo
  154. iface lo inet loopback
  155. # The primary network interface
  156. allow-hotplug eth0
  157. iface eth0 inet static
  158. address 192.168.1.60
  159. netmask 255.255.255.0
  160. gateway 192.168.1.254
  161. dns-nameservers 213.73.91.35 85.214.20.141
  162. # Example to keep MAC address between reboots
  163. #hwaddress ether DA:AD:CE:EF:CA:FE
  164. # WiFi Example
  165. #auto wlan0
  166. #iface wlan0 inet dhcp
  167. # wpa-ssid "essid"
  168. # wpa-psk "password"
  169. # Ethernet/RNDIS gadget (g_ether)
  170. # ... or on host side, usbnet and random hwaddr
  171. # Note on some boards, usb0 is automaticly setup with an init script
  172. # in that case, to completely disable remove file [run_boot-scripts] from the boot partition
  173. #iface usb0 inet static
  174. # address 192.168.7.2
  175. # netmask 255.255.255.0
  176. # network 192.168.7.0
  177. # gateway 192.168.7.1
  178. #+END_SRC
  179. CTRL-o followed by ENTER to save, then CTRL-x to exit.
  180. 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.
  181. "gateway 192.168.1.254" should be the IP address of the router.
  182. Note that setting the DNS servers with dns-nameservers is important because some home routers do not allow you to change the DNS settings.
  183. Edit resolv.conf.
  184. #+BEGIN_SRC: bash
  185. nano /etc/resolv.conf
  186. #+END_SRC
  187. It should look something like the following:
  188. #+BEGIN_SRC: bash
  189. domain localdomain
  190. search localdomain
  191. nameserver 213.73.91.35
  192. nameserver 85.214.20.141
  193. #+END_SRC
  194. CTRL-o followed by ENTER to save, then CTRL-x to exit.
  195. 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.
  196. 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".
  197. ** Add a user
  198. Ssh back in to the BBB and login as root. In this example the BBB's IP address is 192.168.1.60.
  199. #+BEGIN_SRC: bash
  200. ssh-keygen -f "/home/myusername/.ssh/known_hosts" -R 192.168.1.60
  201. ssh debian@192.168.1.60
  202. su
  203. #+END_SRC
  204. 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.
  205. #+BEGIN_SRC: bash
  206. adduser myusername
  207. #+END_SRC
  208. 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.
  209. Remove the default debian user.
  210. #+BEGIN_SRC: bash
  211. userdel -r debian
  212. #+END_SRC
  213. ** Text editor
  214. For an editor which is less erratic than vi when used within a remote console such as Terminator.
  215. #+BEGIN_SRC: bash
  216. apt-get update
  217. apt-get install emacs
  218. update-alternatives --set editor /usr/bin/emacs23
  219. #+END_SRC
  220. Some basic Emacs keys which will be useful to new users are:
  221. | Load a file | CTRL-x CTRL-f |
  222. | Save | CTRL-x CTRL-s |
  223. | Exit | CTRL-x CTRL-c |
  224. ** Enable backports
  225. To enable some newer packages add backports to the repositories.
  226. #+BEGIN_SRC: bash
  227. echo "deb http://ftp.us.debian.org/debian wheezy-backports main" >> /etc/apt/sources.list
  228. apt-get update
  229. apt-get dist-upgrade
  230. apt-get install ca-certificates
  231. #+END_SRC
  232. ** Configure your location/language
  233. #+BEGIN_SRC: bash
  234. dpkg-reconfigure locales
  235. apt-get install keyboard-configuration
  236. reboot
  237. #+END_SRC
  238. After reboot is complete ssh back in as the root user, then to verify the change.
  239. #+BEGIN_SRC: bash
  240. locale -a
  241. #+END_SRC
  242. Set your time zone with:
  243. #+BEGIN_SRC: bash
  244. tzselect
  245. #+END_SRC
  246. For example, for British time:
  247. #+BEGIN_SRC: bash
  248. export TZ='Europe/London'
  249. echo "export TZ='Europe/London'" >> ~/.bashrc
  250. echo "export TZ='Europe/London'" >> /home/myusername/.bashrc
  251. #+END_SRC
  252. ** Upgrade the kernel
  253. Using a more recent kernel should improve stability of the system and also allow it to make use of hardware random number generation, which improves the overall security. Please note that this kernel is specific to the BBB, so if you're using a Raspberry Pi, Cubieboard or other SBC then look elsewhere on the web for information about upgrading the kernel.
  254. #+BEGIN_SRC: bash
  255. cd /tmp
  256. wget http://freedombone.uk.to/kernel-3.14.tar.gz
  257. #+END_SRC
  258. Verify it.
  259. #+BEGIN_SRC: bash
  260. sha256sum kernel-3.14.tar.gz
  261. c489a451b2ab0442ff9105c72307061cfe6858350dacceb29e094b9a20c18739
  262. #+END_SRC
  263. Then extract and install it.
  264. #+BEGIN_SRC: bash
  265. mkdir kernel-3.14
  266. cd kernel-3.14
  267. tar -xzvf ../kernel-3.14.tar.gz
  268. sh install-me.sh
  269. #+END_SRC
  270. If you get a certificate error then edit *install-me.sh* and change the /https/ to /http/, save and try again. Once the installation has completed then you can reboot by typing:
  271. #+BEGIN_SRC: bash
  272. reboot
  273. #+END_SRC
  274. After the system has rebooted you can ssh back unto it and log in as the root user. You can check that the kernel version has changed with the command:
  275. #+BEGIN_SRC: bash
  276. uname -mrs
  277. #+END_SRC
  278. Now enable zram.
  279. #+BEGIN_SRC: bash
  280. editor /etc/modprobe.d/zram.conf
  281. #+END_SRC
  282. Add the following:
  283. #+BEGIN_SRC: bash
  284. options zram num_devices=1
  285. #+END_SRC
  286. Save and exit, then create an initialisation script.
  287. #+BEGIN_SRC: bash
  288. editor /etc/init.d/zram
  289. #+END_SRC
  290. Add the following:
  291. #+BEGIN_SRC: bash
  292. #!/bin/bash
  293. ### BEGIN INIT INFO
  294. # Provides: zram
  295. # Required-Start:
  296. # Required-Stop:
  297. # Default-Start: 2 3 4 5
  298. # Default-Stop: 0 1 6
  299. # Short-Description: Increased Performance In Linux With zRam (Virtual Swap Compressed in RAM)
  300. # Description: Adapted from systemd scripts at https://github.com/mystilleef/FedoraZram
  301. ### END INIT INFO
  302. start() {
  303. # get the number of CPUs
  304. num_cpus=$(grep -c processor /proc/cpuinfo)
  305. # if something goes wrong, assume we have 1
  306. [ "$num_cpus" != 0 ] || num_cpus=1
  307. # set decremented number of CPUs
  308. decr_num_cpus=$((num_cpus - 1))
  309. # get the amount of memory in the machine
  310. mem_total_kb=$(grep MemTotal /proc/meminfo | grep -E --only-matching '[[:digit:]]+')
  311. mem_total=$((mem_total_kb * 1024))
  312. # load dependency modules
  313. modprobe zram num_devices=$num_cpus
  314. # initialize the devices
  315. for i in $(seq 0 $decr_num_cpus); do
  316. echo $((mem_total / num_cpus)) > /sys/block/zram$i/disksize
  317. done
  318. # Creating swap filesystems
  319. for i in $(seq 0 $decr_num_cpus); do
  320. mkswap /dev/zram$i
  321. done
  322. # Switch the swaps on
  323. for i in $(seq 0 $decr_num_cpus); do
  324. swapon -p 100 /dev/zram$i
  325. done
  326. }
  327. stop() {
  328. # get the number of CPUs
  329. num_cpus=$(grep -c processor /proc/cpuinfo)
  330. # set decremented number of CPUs
  331. decr_num_cpus=$((num_cpus - 1))
  332. # Switching off swap
  333. for i in $(seq 0 $decr_num_cpus); do
  334. if [ "$(grep /dev/zram$i /proc/swaps)" != "" ]; then
  335. swapoff /dev/zram$i
  336. sleep 1
  337. fi
  338. done
  339. sleep 1
  340. rmmod zram
  341. }
  342. case "$1" in
  343. start)
  344. start
  345. ;;
  346. stop)
  347. stop
  348. ;;
  349. restart)
  350. stop
  351. sleep 3
  352. start
  353. ;;
  354. *)
  355. echo "Usage: $0 {start|stop|restart}"
  356. RETVAL=1
  357. esac
  358. exit $RETVAL
  359. #+END_SRC
  360. Save and exit, then reboot again.
  361. #+BEGIN_SRC: bash
  362. chmod +x /etc/init.d/zram
  363. update-rc.d zram defaults
  364. service zram start
  365. reboot
  366. #+END_SRC
  367. After the system has rebooted ssh back into it and become the root user, then to check that the changes were successful:
  368. #+BEGIN_SRC: bash
  369. dmesg | grep zram
  370. #+END_SRC
  371. Should show something like:
  372. #+BEGIN_SRC: bash
  373. [ 507.322337] zram: Created 1 device(s) ...
  374. [ 507.651151] Adding 505468k swap on /dev/zram0. Priority:100 extents:1 across:505468k SS
  375. #+END_SRC
  376. ** Random number generation
  377. #+BEGIN_VERSE
  378. /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./
  379. -- Bruce Schneier, on the 2013 leaked NSA documents
  380. #+END_VERSE
  381. 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.
  382. *** On the Beaglebone Black
  383. Computers can't really generate truly random numbers by themselves, since they're deterministic and so operate in a highly predictable manner. Fortunately, the BBB has an onboard hardware random number generator, which is a physical process which behaves randomly and which can then be read into the computer and stored for later use in encryption algorithms.
  384. Information on exactly how the hardware random number generator on the Beaglebone AM335x CPU works [[http://e2e.ti.com/support/arm/sitara_arm/f/791/t/292794.aspx][seems hard to come by]], but we can later use some software to verify that it does indeed produce random numbers and hasn't been deliberately weakened.
  385. If you are using a Beaglebone and have updated the kernel then install:
  386. #+BEGIN_SRC: bash
  387. apt-get install rng-tools
  388. editor /etc/default/rng-tools
  389. #+END_SRC
  390. Uncomment *HRNGDEVICE=/dev/hwrng*, save and exit then restart the daemon.
  391. #+BEGIN_SRC: bash
  392. service rng-tools restart
  393. #+END_SRC
  394. Your BBB will now use hardware to generate random numbers.
  395. *** On other Single Board Computers
  396. If you are not using a Beaglebone (a Cubieboard for example), or if you didn't update the kernel, then you can still improve the random number generation by installing:
  397. #+BEGIN_SRC: bash
  398. apt-get install haveged
  399. #+END_SRC
  400. *** Verifying random number quality
  401. #+BEGIN_VERSE
  402. /Living in a surveillance state is exactly like being guilty until proven guilty./
  403. -- Mohammad Tarakiyee
  404. #+END_VERSE
  405. You can check how much randomness (entropy) is available with:
  406. #+BEGIN_SRC: bash
  407. cat /proc/sys/kernel/random/entropy_avail
  408. #+END_SRC
  409. Ideally it should be in the range 1000-4096. If it is persistently below 500 then there may be a problem with your system which could make it less secure.
  410. To verify that random number generation is good on the BBB run:
  411. #+BEGIN_SRC: bash
  412. cat /dev/hwrng | rngtest -c 1000
  413. #+END_SRC
  414. You should see something like this, with zero or a small number of failures:
  415. #+BEGIN_SRC: bash
  416. rngtest: starting FIPS tests...
  417. rngtest: bits received from input: 20000032
  418. rngtest: FIPS 140-2 successes: 1000
  419. rngtest: FIPS 140-2 failures: 0
  420. rngtest: FIPS 140-2(2001-10-10) Monobit: 0
  421. rngtest: FIPS 140-2(2001-10-10) Poker: 0
  422. rngtest: FIPS 140-2(2001-10-10) Runs: 0
  423. rngtest: FIPS 140-2(2001-10-10) Long run: 0
  424. rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
  425. rngtest: input channel speed: (min=3.104; avg=26.015; max=18.626)Gibits/s
  426. rngtest: FIPS tests speed: (min=160.281; avg=165.696; max=168.792)Mibits/s
  427. rngtest: Program run time: 115987 microseconds
  428. #+END_SRC
  429. *** Cryptotronix Hashlet
  430. #+BEGIN_VERSE
  431. /One must acknowledge with cryptography no amount of violence will ever solve a math problem./
  432. -- Jacob Appelbaum
  433. #+END_VERSE
  434. An optional extra is the [[http://cryptotronix.com/products/hashlet/][Cryptotronix Hashlet]] which also has hardware random number generation capability via the [[./Atmel-8740-CryptoAuth-ATSHA204-Datasheet.pdf][Atmel ATSHA204]] chip.
  435. Install the hashlet [[./images/hashlet_installed.jpg][like this]] on the BBB, then install some dependencies.
  436. #+BEGIN_SRC: bash
  437. apt-get install git build-essential libgcrypt11-dev texinfo
  438. #+END_SRC
  439. Download the source code.
  440. #+BEGIN_SRC: bash
  441. cd /tmp
  442. git clone https://github.com/bashrc/hashlet.git
  443. #+END_SRC
  444. Now install the driver.
  445. #+BEGIN_SRC: bash
  446. cd hashlet
  447. chmod o+rw /dev/i2c*
  448. ./autogen.sh
  449. make check
  450. make install
  451. #+END_SRC
  452. To check the initial state of the device:
  453. #+BEGIN_SRC: bash
  454. hashlet --bus=/dev/i2c-2 state
  455. #+END_SRC
  456. It should return the message "/Factory/". This is intended to provide an indication that the hardware hasn't been tampered with by [[https://en.wikipedia.org/wiki/Tailored_Access_Operations][TAO]] or other shady outfits in transit. If /i2c-2/ fails then try /i2c-1/ or /i2c-0/.
  457. #+BEGIN_SRC: bash
  458. hashlet --bus=/dev/i2c-2 personalize
  459. #+END_SRC
  460. Nothing should be returned by this command, but a file called ~/.hashlet will be generated which is the private key of the device. This personalization process is a one-time operation which physically alters the hardware, so it would not be trivial to reset the device back to "Factory" again. To make sure it's only accessible by the root user:
  461. #+BEGIN_SRC: bash
  462. chmod 400 ~/.hashlet
  463. #+END_SRC
  464. Now create a daemon which will create a random number generator device */dev/hashletrng*.
  465. #+BEGIN_SRC: bash
  466. editor /usr/bin/hashletd
  467. #+END_SRC
  468. #+BEGIN_SRC: bash
  469. #!/bin/sh
  470. PATH='/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/bin'
  471. I2CBUS=2
  472. BYTES=32
  473. DEVICE=/dev/hashletrng
  474. # create a device
  475. if [ ! -e ${DEVICE} ]; then
  476. chmod o+rw /dev/i2c*
  477. mknod ${DEVICE} p
  478. fi
  479. while :
  480. do
  481. hashlet --bus=/dev/i2c-${I2CBUS} --Bytes ${BYTES} random-bytes > ${DEVICE}
  482. done
  483. #+END_SRC
  484. Save and exit. Now create an init script to run it.
  485. #+BEGIN_SRC: bash
  486. editor /etc/init.d/hashlet
  487. #+END_SRC
  488. Add the following:
  489. #+BEGIN_SRC: bash
  490. #!/bin/bash
  491. # /etc/init.d/hashlet
  492. ### BEGIN INIT INFO
  493. # Provides: hashlet
  494. # Required-Start: $remote_fs $syslog
  495. # Required-Stop: $remote_fs $syslog
  496. # Default-Start: 2 3 4 5
  497. # Default-Stop: 0 1 6
  498. # Short-Description: hashlet
  499. # Description: Creates a random number generator device
  500. ### END INIT INFO
  501. # Author: Bob Mottram <bob@robotics.uk.to>
  502. #Settings
  503. SERVICE='hashlet'
  504. LOGFILE='/dev/null'
  505. COMMAND="/usr/bin/hashletd"
  506. USERNAME='root'
  507. NICELEVEL=19
  508. HISTORY=1024
  509. INVOCATION="nice -n ${NICELEVEL} ${COMMAND}"
  510. PATH='/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/bin'
  511. hashlet_start() {
  512. echo "Starting $SERVICE..."
  513. su --command "screen -h ${HISTORY} -dmS ${SERVICE} ${INVOCATION}" $USERNAME
  514. }
  515. hashlet_stop() {
  516. echo "Stopping $SERVICE"
  517. su --command "screen -p 0 -S ${SERVICE} -X stuff "'^C'"" $USERNAME
  518. }
  519. #Start-Stop here
  520. case "$1" in
  521. start)
  522. hashlet_start
  523. ;;
  524. stop)
  525. hashlet_stop
  526. ;;
  527. restart)
  528. hashlet_stop
  529. sleep 10s
  530. hashlet_start
  531. ;;
  532. *)
  533. echo "Usage: $0 {start|stop|restart}"
  534. exit 1
  535. ;;
  536. esac
  537. exit 0
  538. #+END_SRC
  539. Save and exit, then start the daemon.
  540. #+BEGIN_SRC: bash
  541. chmod +x /usr/bin/hashletd
  542. chmod +x /etc/init.d/hashlet
  543. update-rc.d hashlet defaults
  544. service hashlet start
  545. #+END_SRC
  546. Then to obtain some random bytes:
  547. #+BEGIN_SRC: bash
  548. cat /dev/hashletrng
  549. #+END_SRC
  550. The rate of entropy generation by the Hashlet seems very slow compared to */dev/hwrng*, and this is most likely because of the I2C interface. So it's probably a good idea to keep hwrng as the main random source and only use the Hashlet's random number generator for any ancillary stuff.
  551. ** Alter ssh configuration
  552. Altering the ssh configuration will make it a little more secure than the standard Debian settings.
  553. #+BEGIN_SRC: bash
  554. editor /etc/ssh/sshd_config
  555. #+END_SRC
  556. Check the following values:
  557. #+BEGIN_SRC: bash
  558. PermitRootLogin no
  559. X11Forwarding no
  560. ServerKeyBits 4096
  561. Protocol 2
  562. PermitEmptyPasswords no
  563. StrictModes yes
  564. TCPKeepAlive no
  565. #+END_SRC
  566. Append the following:
  567. #+BEGIN_SRC: bash
  568. ClientAliveInterval 60
  569. ClientAliveCountMax 3
  570. Ciphers aes256-ctr,aes192-ctr,aes128-ctr
  571. MACs hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
  572. KexAlgorithms diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1
  573. #+END_SRC
  574. CTRL-x CTRL-s to save, then CTRL-x CTRL-c to exit. Now clear out any pre-existing host keys and reconfigure the ssh server.
  575. #+BEGIN_SRC: bash
  576. rm /etc/ssh/ssh_host_*
  577. dpkg-reconfigure openssh-server
  578. service ssh restart
  579. #+END_SRC
  580. To test the new settings log out by typing "exit" a couple of times, then log back in again with:
  581. #+BEGIN_SRC: bash
  582. ssh -vvv myusername@192.168.1.60
  583. #+END_SRC
  584. and check that some number of bits are set within a 4096 bit sized key:
  585. #+BEGIN_SRC: bash
  586. debug2: bits set: */4096
  587. #+END_SRC
  588. ** Getting onto the web
  589. 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.
  590. Select "/dynamic DNS/" then click "/quick cron example/"
  591. An example would look like:
  592. #+BEGIN_SRC: bash
  593. 4,14,24,34,44,54 * * * * root sleep 29 ; /usr/bin/timeout 200 wget -O - https://free\ dns.afraid.org/dynamic/update.php?ABCKDNRCLFHENSLKNFEGSBFLFF== >> /dev/null 2>&1 &
  594. #+END_SRC
  595. It's important to make sure that you change the *http* to *https*, since this will help to prevent a potential attacker from hijacking your site and redirecting it to a fake version for the purposes of obtaining your login details.
  596. Edit */etc/crontab* and append that to the top of the file, underneath the heading line which looks like this:
  597. #+BEGIN_SRC: bash
  598. # m h dom mon dow user command
  599. #+END_SRC
  600. In general the most frequently run crontab entries should be at the top. Then save and exit.
  601. 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.
  602. The freeDNS subdomain which you just created will hereafter just be refered to as "/your domain name/".
  603. If you have multiple freedns subdomains then you may want to rationalise that a little within */etc/crontab*. Rather than listing them all individually create a script:
  604. #+BEGIN_SRC: bash
  605. editor /usr/bin/dynamicdns
  606. #+END_SRC
  607. Add however many freedns subdomains you have.
  608. #+BEGIN_SRC: bash
  609. #!/bin/bash
  610. # subdomain name 1
  611. wget -O - https://freedns.afraid.org/dynamic/update.php?<subdomain code 1>== >> /dev/null 2>&1
  612. # subdomain name 2
  613. wget -O - https://freedns.afraid.org/dynamic/update.php?<subdomain code 2>== >> /dev/null 2>&1
  614. ...
  615. #+END_SRC
  616. Save and exit, then make the script runnable and only readable by the root user.
  617. #+BEGIN_SRC: bash
  618. chmod 600 /usr/bin/dynamicdns
  619. chmod +x /usr/bin/dynamicdns
  620. #+END_SRC
  621. Then within */etc/crontab*
  622. #+BEGIN_SRC: bash
  623. editor /etc/crontab
  624. #+END_SRC
  625. You can replace the multiple freedns entries with a single line:
  626. #+BEGIN_SRC: bash
  627. */10 * * * * root /usr/bin/timeout 200 /usr/bin/dynamicdns
  628. #+END_SRC
  629. Then save and exit and restart the cron daemon.
  630. #+BEGIN_SRC: bash
  631. service cron restart
  632. #+END_SRC
  633. If you want to know what a typical /crontab/ file might look like then see the [[Example crontab file]]
  634. ** Set the host name
  635. #+BEGIN_SRC: bash
  636. editor /etc/hostname
  637. #+END_SRC
  638. CTRL-x CTRL-s to save, then CTRL-x CTRL-c to exit.
  639. Also issue the command, replacing /mydomainname.com/ with your domain name.
  640. #+BEGIN_SRC: bash
  641. hostname mydomainname.com
  642. #+END_SRC
  643. You may also need to assign the same hostname separately via your router's web interface.
  644. #+BEGIN_SRC: bash
  645. editor /etc/hosts
  646. #+END_SRC
  647. Append the following, replacing /mydomainname.com/ with your domain name.
  648. #+BEGIN_SRC: bash
  649. 127.0.1.1 mydomainname.com
  650. #+END_SRC
  651. If you then run the command:
  652. #+BEGIN_SRC: bash
  653. hostname -f
  654. #+END_SRC
  655. it should return your domain name.
  656. ** Install time synchronisation
  657. #+BEGIN_VERSE
  658. /You may delay, but time will not./
  659. -- Benjamin Franklin
  660. #+END_VERSE
  661. It's convenient to have the clock on your server automatically synchronised with other servers on the internet so that you don't need to set the clock manually. The usual way of doing this is via [[https://en.wikipedia.org/wiki/Network_Time_Protocol][NTP]], but that method uses unencrypted signals which could potentially be interfered with in order to mess up your system. /tlsdate/ provides a slightly more secure way of setting the date and time over a SSL/TLS connection to a known good time source.
  662. First install some prerequisites.
  663. #+BEGIN_SRC: bash
  664. apt-get install build-essential automake git pkg-config autoconf libtool libssl-dev
  665. #+END_SRC
  666. Now download and install tlsdate.
  667. #+BEGIN_SRC: bash
  668. mkdir ~/build
  669. cd ~/build
  670. git clone https://github.com/ioerror/tlsdate.git
  671. cd ~/build/tlsdate
  672. ./autogen.sh
  673. ./configure
  674. make
  675. make install
  676. #+END_SRC
  677. If you get errors during the /configure/ stage then you may need to reboot so that some of the installed dependencies take effect.
  678. #+BEGIN_SRC: bash
  679. editor /etc/crontab
  680. #+END_SRC
  681. Add the following near the top of the list of tasks.
  682. #+BEGIN_SRC: bash
  683. */15 * * * * root /usr/bin/timeout 20 tlsdate -l -t -H www.ptb.de -p 443 >> /var/log/tlsdate.log
  684. #+END_SRC
  685. Save and exit.
  686. #+BEGIN_SRC: bash
  687. service cron restart
  688. #+END_SRC
  689. This obtains the date and time from www.ptb.de every 15 minutes. Obviously if you wish to use a different source for the date and time then the cron entry can be edited accordingly.
  690. ** Install fail2ban
  691. #+BEGIN_SRC: bash
  692. apt-get install fail2ban
  693. #+END_SRC
  694. ** Set up a firewall
  695. #+BEGIN_VERSE
  696. /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/
  697. -- NBC News article: /War on Anonymous: British Spies Attacked Hackers, Snowden Docs Show/
  698. #+END_VERSE
  699. 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.
  700. #+BEGIN_SRC: bash
  701. apt-get install portsentry
  702. editor /etc/portsentry/portsentry.conf
  703. #+END_SRC
  704. Uncomment the entry for *iptables support for Linux*
  705. Set the following properties:
  706. #+BEGIN_SRC: bash
  707. 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"
  708. 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"
  709. ADVANCED_EXCLUDE_TCP="113,139,70,80,443,143,6670,993,5060,5061,25,465,22,5222,5223,5269,5280,5281,8432,8433,8444"
  710. ADVANCED_EXCLUDE_UDP="520,138,137,67,70,80,443,143,6670,993, 5060,5061,25,465,22,5222,5223,5269,5280,5281,8444"
  711. SCAN_TRIGGER="2"
  712. BLOCK_UDP="2"
  713. BLOCK_TCP="2"
  714. #+END_SRC
  715. Save and exit.
  716. #+BEGIN_SRC: bash
  717. service portsentry restart
  718. editor /tmp/firewall.sh
  719. #+END_SRC
  720. Enter the following:
  721. #+BEGIN_SRC: bash
  722. #!/bin/bash
  723. # First of all delete any existing rules.
  724. # This means you're back to a known state:
  725. iptables -P INPUT ACCEPT
  726. ip6tables -P INPUT ACCEPT
  727. iptables -F
  728. ip6tables -F
  729. iptables -X
  730. ip6tables -X
  731. # Drop any IPv6 traffic
  732. ip6tables -A INPUT -p icmp -j DROP
  733. ip6tables -A INPUT -p tcp -j DROP
  734. ip6tables -A INPUT -p udp -j DROP
  735. # Drop access to unused ports
  736. iptables -A INPUT -p tcp --destination-port 1 -j DROP
  737. iptables -A INPUT -p tcp --destination-port 7 -j DROP
  738. iptables -A INPUT -p tcp --destination-port 109:111 -j DROP
  739. iptables -A INPUT -p tcp --destination-port 995 -j DROP
  740. iptables -A INPUT -p tcp --destination-port 139 -j DROP
  741. iptables -A INPUT -p tcp --destination-port 6000:6001 -j DROP
  742. iptables -A INPUT -p tcp --destination-port 9 -j DROP
  743. iptables -A INPUT -p tcp --destination-port 79 -j DROP
  744. iptables -A INPUT -p tcp --destination-port 515 -j DROP
  745. iptables -A INPUT -p tcp --destination-port 4001 -j DROP
  746. iptables -A INPUT -p tcp --destination-port 1524 -j DROP
  747. iptables -A INPUT -p tcp --destination-port 1080 -j DROP
  748. iptables -A INPUT -p tcp --destination-port 512:514 -j DROP
  749. iptables -A INPUT -p tcp --destination-port 31337 -j DROP
  750. iptables -A INPUT -p tcp --destination-port 2000:2001 -j DROP
  751. iptables -A INPUT -p tcp --destination-port 12345 -j DROP
  752. iptables -A INPUT -p tcp --destination-port 32771:32774 -j DROP
  753. iptables -A INPUT -p tcp --destination-port 4000 -j DROP
  754. iptables -A INPUT -p tcp --destination-port 119 -j DROP
  755. iptables -A INPUT -p tcp --destination-port 137 -j DROP
  756. iptables -A INPUT -p tcp --destination-port 3306 -j DROP
  757. iptables -A INPUT -p tcp --destination-port 4242 -j DROP
  758. iptables -A INPUT -p tcp --destination-port 9050 -j DROP
  759. iptables -A INPUT -p udp --destination-port 1 -j DROP
  760. iptables -A INPUT -p udp --destination-port 7 -j DROP
  761. iptables -A INPUT -p udp --destination-port 109:111 -j DROP
  762. iptables -A INPUT -p udp --destination-port 995 -j DROP
  763. iptables -A INPUT -p udp --destination-port 139 -j DROP
  764. iptables -A INPUT -p udp --destination-port 6000:6001 -j DROP
  765. iptables -A INPUT -p udp --destination-port 9 -j DROP
  766. iptables -A INPUT -p udp --destination-port 79 -j DROP
  767. iptables -A INPUT -p udp --destination-port 515 -j DROP
  768. iptables -A INPUT -p udp --destination-port 4001 -j DROP
  769. iptables -A INPUT -p udp --destination-port 1524 -j DROP
  770. iptables -A INPUT -p udp --destination-port 1080 -j DROP
  771. iptables -A INPUT -p udp --destination-port 512:514 -j DROP
  772. iptables -A INPUT -p udp --destination-port 31337 -j DROP
  773. iptables -A INPUT -p udp --destination-port 2000:2001 -j DROP
  774. iptables -A INPUT -p udp --destination-port 12345 -j DROP
  775. iptables -A INPUT -p udp --destination-port 32771:32774 -j DROP
  776. iptables -A INPUT -p udp --destination-port 4000 -j DROP
  777. iptables -A INPUT -p udp --destination-port 119 -j DROP
  778. iptables -A INPUT -p udp --destination-port 137 -j DROP
  779. iptables -A INPUT -p udp --destination-port 8432 -j DROP
  780. iptables -A INPUT -p udp --destination-port 8433 -j DROP
  781. iptables -A INPUT -p udp --destination-port 3306 -j DROP
  782. iptables -A INPUT -p udp --destination-port 4242 -j DROP
  783. iptables -A INPUT -p udp --destination-port 9050 -j DROP
  784. # Make sure NEW incoming tcp connections are SYN packets
  785. iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
  786. # Drop packets with incoming fragments
  787. iptables -A INPUT -f -j DROP
  788. # Incoming malformed XMAS packets drop them
  789. iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
  790. iptables -A INPUT -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP
  791. iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
  792. # Incoming malformed NULL packets:
  793. iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
  794. # Drop UDP to used ports
  795. iptables -A INPUT -p udp --match multiport --dports 70,80,443,143,6670,993,5060,5061,25 -j DROP
  796. iptables -A INPUT -p udp --match multiport --dports 465,22,5222,5223,5269,5280,5281,8444 -j DROP
  797. # Limit ssh logins
  798. iptables -A INPUT -p tcp --dport 22 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  799. # Limit web connections
  800. iptables -A INPUT -p tcp --dport 80 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  801. iptables -A INPUT -p tcp --dport 443 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  802. # Limit number of XMPP connections
  803. iptables -A INPUT -p tcp --match multiport --dports 5222:5223,5269,5280:5281 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  804. # Limit IRC connections
  805. iptables -A INPUT -p tcp --dport 6666:6670 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  806. # Limit gopher connections
  807. iptables -A INPUT -p tcp --dport 70 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  808. # Limit IMAP connections
  809. iptables -A INPUT -p tcp --dport 143 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  810. iptables -A INPUT -p tcp --dport 993 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  811. # Limit SIP connections
  812. iptables -A INPUT -p tcp --dport 5060:5061 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  813. # Limit SMTP/SMTPS connections
  814. iptables -A INPUT -p tcp --dport 25 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  815. iptables -A INPUT -p tcp --dport 465 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  816. # Limit Bitmessage connections
  817. iptables -A INPUT -p tcp --dport 8444 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  818. # Limit Convergence notary
  819. iptables -A INPUT -p tcp --dport 8432:8433 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  820. # Limit the number of incoming tcp connections
  821. # Interface 0 incoming syn-flood protection
  822. iptables -N syn_flood
  823. iptables -A INPUT -p tcp --syn -j syn_flood
  824. iptables -A syn_flood -m limit --limit 1/s --limit-burst 3 -j RETURN
  825. iptables -A syn_flood -j DROP
  826. # Limiting the incoming icmp ping request:
  827. #iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 1 -j ACCEPT
  828. #iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 1 -j LOG --log-prefix PING-DROP:
  829. iptables -A INPUT -p icmp -j DROP
  830. #iptables -A OUTPUT -p icmp -j ACCEPT
  831. # Save the settings
  832. iptables-save > /etc/firewall.conf
  833. ip6tables-save > /etc/firewall6.conf
  834. printf '#!/bin/sh\n' > /etc/network/if-up.d/iptables
  835. printf 'iptables-restore < /etc/firewall.conf\n' >> /etc/network/if-up.d/iptables
  836. printf 'ip6tables-restore < /etc/firewall6.conf\n' >> /etc/network/if-up.d/iptables
  837. chmod +x /etc/network/if-up.d/iptables
  838. #+END_SRC
  839. Save and exit.
  840. 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.
  841. #+BEGIN_SRC: bash
  842. chmod +x /tmp/firewall.sh
  843. . /tmp/firewall.sh
  844. rm /tmp/firewall.sh
  845. #+END_SRC
  846. 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.
  847. #+BEGIN_SRC: bash
  848. editor /etc/sysctl.conf
  849. #+END_SRC
  850. Uncomment or change the following:
  851. #+BEGIN_SRC: bash
  852. net.ipv4.tcp_syncookies = 1
  853. net.ipv4.conf.all.accept_redirects = 0
  854. net.ipv6.conf.all.accept_redirects = 0
  855. net.ipv4.conf.all.send_redirects = 0
  856. net.ipv4.conf.all.accept_source_route = 0
  857. net.ipv6.conf.all.accept_source_route = 0
  858. net.ipv4.conf.default.rp_filter=1
  859. net.ipv4.conf.all.rp_filter=1
  860. net.ipv4.ip_forward=0
  861. net.ipv6.conf.all.forwarding=0
  862. #+END_SRC
  863. And append the following:
  864. #+BEGIN_SRC: bash
  865. # ignore pings
  866. net.ipv4.icmp_echo_ignore_all = 1
  867. net.ipv6.icmp_echo_ignore_all = 1
  868. # disable ipv6
  869. net.ipv6.conf.all.disable_ipv6 = 1
  870. net.ipv4.tcp_synack_retries = 2
  871. net.ipv4.tcp_syn_retries = 1
  872. # keepalive
  873. net.ipv4.tcp_keepalive_probes = 9
  874. net.ipv4.tcp_keepalive_intvl = 75
  875. net.ipv4.tcp_keepalive_time = 7200
  876. #+END_SRC
  877. 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:
  878. #+BEGIN_SRC: bash
  879. reboot
  880. #+END_SRC
  881. After reboot and logging back in to the root account via /ssh/ you can verify that the firewall rules were restored correctly with:
  882. #+BEGIN_SRC: bash
  883. iptables -L
  884. #+END_SRC
  885. and
  886. #+BEGIN_SRC: bash
  887. ip6tables -L
  888. #+END_SRC
  889. ** Install Email
  890. #+BEGIN_VERSE
  891. /If you knew what I know about email, you might not use it/
  892. -- Ladar Levison
  893. #+END_VERSE
  894. 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.
  895. Exim4 seems much easier to install and configure than Postfix.
  896. #+BEGIN_SRC: bash
  897. service postfix stop
  898. apt-get remove postfix
  899. aptitude install exim4 sasl2-bin swaks libnet-ssleay-perl procmail
  900. #+END_SRC
  901. You will be prompted to remove postfix. Say yes and yes again.
  902. #+BEGIN_SRC: bash
  903. dpkg-reconfigure exim4-config
  904. #+END_SRC
  905. Settings as follows:
  906. #+BEGIN_SRC: bash
  907. internet site
  908. System mail name: mydomainname.com
  909. IP addresses to listen on: blank
  910. Destinations: mydomainname.com
  911. Domains to relay mail: blank
  912. Smarthost Relay: 192.168.1.0/24 (the range of addresses on your LAN)
  913. Dial on demand = no
  914. Maildir format in home directory
  915. Split configuration = no
  916. Root and postmaster: root email
  917. #+END_SRC
  918. To test the installation:
  919. #+BEGIN_SRC: bash
  920. telnet 192.168.1.60 25
  921. ehlo xxx
  922. quit
  923. #+END_SRC
  924. #+BEGIN_SRC: bash
  925. editor /etc/default/saslauthd
  926. #+END_SRC
  927. set START=yes then save and exit.
  928. #+BEGIN_SRC: bash
  929. /etc/init.d/saslauthd start
  930. editor exim-gencert
  931. #+END_SRC
  932. #+BEGIN_SRC: bash
  933. #!/bin/sh -e
  934. if [ -n "$EX4DEBUG" ]; then
  935. echo "now debugging $0 $@"
  936. set -x
  937. fi
  938. DIR=/etc/exim4
  939. CERT=$DIR/exim.crt
  940. KEY=$DIR/exim.key
  941. # This exim binary was built with GnuTLS which does not support dhparams
  942. # from a file. See /usr/share/doc/exim4-base/README.Debian.gz
  943. #DH=$DIR/exim.dhparam
  944. if ! which openssl > /dev/null ;then
  945. echo "$0: openssl is not installed, exiting" 1>&2
  946. exit 1
  947. fi
  948. # valid for ten years
  949. DAYS=3650
  950. if [ "$1" != "--force" ] && [ -f $CERT ] && [ -f $KEY ]; then
  951. echo "[*] $CERT and $KEY exists!"
  952. echo " Use \"$0 --force\" to force generation!"
  953. exit 0
  954. fi
  955. if [ "$1" = "--force" ]; then
  956. shift
  957. fi
  958. #SSLEAY=/tmp/exim.ssleay.$$.cnf
  959. SSLEAY="$(tempfile -m600 -pexi)"
  960. cat > $SSLEAY <<EOM
  961. RANDFILE = $HOME/.rnd
  962. [ req ]
  963. default_bits = 4096
  964. default_keyfile = exim.key
  965. distinguished_name = req_distinguished_name
  966. [ req_distinguished_name ]
  967. countryName = Country Code (2 letters)
  968. countryName_default = GB
  969. countryName_min = 2
  970. countryName_max = 2
  971. stateOrProvinceName = State or Province Name (full name)
  972. localityName = Locality Name (eg, city)
  973. organizationName = Organization Name (eg, company; recommended)
  974. organizationName_max = 64
  975. organizationalUnitName = Organizational Unit Name (eg, section)
  976. organizationalUnitName_max = 64
  977. commonName = Server name (eg. ssl.domain.tld; required!!!)
  978. commonName_max = 64
  979. emailAddress = Email Address
  980. emailAddress_max = 40
  981. EOM
  982. echo "[*] Creating a self signed SSL certificate for Exim!"
  983. echo " This may be sufficient to establish encrypted connections but for"
  984. echo " secure identification you need to buy a real certificate!"
  985. echo " "
  986. echo " Please enter the hostname of your MTA at the Common Name (CN) prompt!"
  987. echo " "
  988. openssl req -config $SSLEAY -x509 -sha256 -newkey rsa:4096 -keyout $KEY -out $CERT -days $DAYS -nodes
  989. #see README.Debian.gz*# openssl dhparam -check -text -5 512 -out $DH
  990. rm -f $SSLEAY
  991. chown root:Debian-exim $KEY $CERT $DH
  992. chmod 640 $KEY $CERT $DH
  993. echo "[*] Done generating self signed certificates for exim!"
  994. echo " Refer to the documentation and example configuration files"
  995. echo " over at /usr/share/doc/exim4-base/ for an idea on how to enable TLS"
  996. echo " support in your mail transfer agent."
  997. #+END_SRC
  998. Save and exit
  999. #+BEGIN_SRC: bash
  1000. chmod +x exim-gencert
  1001. ./exim-gencert
  1002. #+END_SRC
  1003. 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.
  1004. #+BEGIN_SRC: bash
  1005. editor /etc/exim4/exim4.conf.template
  1006. #+END_SRC
  1007. Append the following:
  1008. #+BEGIN_SRC: bash
  1009. login_saslauthd_server:
  1010. driver = plaintext
  1011. public_name = LOGIN
  1012. server_prompts = "Username:: : Password::"
  1013. # don't send system passwords over unencrypted connections
  1014. server_condition = ${if saslauthd{{$auth1}{$auth2}}{1}{0}}
  1015. server_set_id = $auth1
  1016. .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
  1017. server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
  1018. .endif
  1019. #+END_SRC
  1020. Search for the line *.ifdef MAIN_HARDCODE_PRIMARY_HOSTNAME* and above it insert the line:
  1021. #+BEGIN_SRC: bash
  1022. MAIN_HARDCODE_PRIMARY_HOSTNAME = mydomainname.com
  1023. #+END_SRC
  1024. Add the line:
  1025. #+BEGIN_SRC: bash
  1026. MAIN_TLS_ENABLE = true
  1027. #+END_SRC
  1028. Save and exit.
  1029. #+BEGIN_SRC: bash
  1030. editor /etc/default/exim4
  1031. change SMTPLISTENEROPTIONS to:
  1032. SMTPLISTENEROPTIONS='-oX 465:25 -oP /var/run/exim4/exim.pid'
  1033. #+END_SRC
  1034. save and exit
  1035. #+BEGIN_SRC: bash
  1036. editor /etc/exim4/exim4.conf.template
  1037. under the section "main/03_exim4-config_tlsoptions"
  1038. Add the following:
  1039. tls_on_connect_ports=465
  1040. #+END_SRC
  1041. save and exit
  1042. #+BEGIN_SRC: bash
  1043. adduser myusername sasl
  1044. addgroup Debian-exim sasl
  1045. /etc/init.d/exim4 restart
  1046. mkdir -m 700 /etc/skel/Maildir
  1047. mkdir -m 700 /etc/skel/Maildir/Sent
  1048. mkdir -m 700 /etc/skel/Maildir/Sent/tmp
  1049. mkdir -m 700 /etc/skel/Maildir/Sent/cur
  1050. mkdir -m 700 /etc/skel/Maildir/Sent/new
  1051. mkdir -m 700 /etc/skel/Maildir/.learn-spam
  1052. mkdir -m 700 /etc/skel/Maildir/.learn-spam/cur
  1053. mkdir -m 700 /etc/skel/Maildir/.learn-spam/new
  1054. mkdir -m 700 /etc/skel/Maildir/.learn-spam/tmp
  1055. mkdir -m 700 /etc/skel/Maildir/.learn-ham
  1056. mkdir -m 700 /etc/skel/Maildir/.learn-ham/cur
  1057. mkdir -m 700 /etc/skel/Maildir/.learn-ham/new
  1058. mkdir -m 700 /etc/skel/Maildir/.learn-ham/tmp
  1059. ln -s /etc/skel/Maildir/.learn-spam /etc/skel/Maildir/spam
  1060. ln -s /etc/skel/Maildir/.learn-ham /etc/skel/Maildir/ham
  1061. #+END_SRC
  1062. If you're starting from scratch and don't already have a /Maildir/ directory in your home directory, then create one as follows:
  1063. #+BEGIN_SRC: bash
  1064. export MYUSERNAME=myusername
  1065. mkdir -m 700 /home/$MYUSERNAME/Maildir
  1066. mkdir -m 700 /home/$MYUSERNAME/Maildir/cur
  1067. mkdir -m 700 /home/$MYUSERNAME/Maildir/tmp
  1068. mkdir -m 700 /home/$MYUSERNAME/Maildir/new
  1069. mkdir -m 700 /home/$MYUSERNAME/Maildir/Sent
  1070. mkdir -m 700 /home/$MYUSERNAME/Maildir/Sent/cur
  1071. mkdir -m 700 /home/$MYUSERNAME/Maildir/Sent/tmp
  1072. mkdir -m 700 /home/$MYUSERNAME/Maildir/Sent/new
  1073. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-spam
  1074. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-spam/cur
  1075. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-spam/new
  1076. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-spam/tmp
  1077. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-ham
  1078. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-ham/cur
  1079. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-ham/new
  1080. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-ham/tmp
  1081. ln -s /home/$MYUSERNAME/Maildir/.learn-spam /home/$MYUSERNAME/Maildir/spam
  1082. ln -s /home/$MYUSERNAME/Maildir/.learn-ham /home/$MYUSERNAME/Maildir/ham
  1083. chown -R $MYUSERNAME:$MYUSERNAME /home/$MYUSERNAME/Maildir
  1084. #+END_SRC
  1085. ** Spam filtering
  1086. #+BEGIN_SRC: bash
  1087. apt-get install spamassassin exim4-daemon-heavy
  1088. editor /etc/default/spamassassin
  1089. #+END_SRC
  1090. Set ENABLED=1 then save and exit.
  1091. #+BEGIN_SRC: bash
  1092. editor /etc/exim4/exim4.conf.template
  1093. #+END_SRC
  1094. uncomment or change according to your configuration
  1095. #+BEGIN_SRC: bash
  1096. # For spam scanning, there is a similar option that defines the interface to
  1097. # SpamAssassin. You do not need to set this if you are using the default, which
  1098. # is shown in this commented example. As for virus scanning, you must also
  1099. # modify the acl_check_data access control list to enable spam scanning.
  1100. spamd_address = 127.0.0.1 783
  1101. #+END_SRC
  1102. add spam header in the /acl_check_data/ section:
  1103. #+BEGIN_SRC: bash
  1104. ### acl/40_exim4-config_check_data
  1105. #################################
  1106. # This ACL is used after the contents of a message have been received. This
  1107. # is the ACL in which you can test a message's headers or body, and in
  1108. # particular, this is where you can invoke external virus or spam scanners.
  1109. acl_check_data:
  1110. ...
  1111. ...
  1112. ...
  1113. # See the exim docs and the exim wiki for more suitable examples.
  1114. #
  1115. # warn
  1116. # spam = Debian-exim:true
  1117. # add_header = X-Spam_score: $spam_score\n\
  1118. # X-Spam_score_int: $spam_score_int\n\
  1119. # X-Spam_bar: $spam_bar\n\
  1120. # X-Spam_report: $spam_report
  1121. # put headers in all messages (no matter if spam or not)
  1122. warn spam = nobody:true
  1123. add_header = X-Spam-Score: $spam_score ($spam_bar)
  1124. add_header = X-Spam-Report: $spam_report
  1125. # add second subject line with *SPAM* marker when message
  1126. # is over threshold
  1127. warn spam = nobody
  1128. add_header = Subject: ***SPAM (score:$spam_score)*** $h_Subject:
  1129. #+END_SRC
  1130. Save and exit.
  1131. Then restart
  1132. #+BEGIN_SRC: bash
  1133. exit
  1134. editor ~/.procmailrc
  1135. #+END_SRC
  1136. The text should look like the following.
  1137. #+BEGIN_SRC: sh
  1138. MAILDIR=$HOME/Maildir
  1139. DEFAULT=$MAILDIR/
  1140. LOGFILE=$HOME/log/procmail.log
  1141. LOGABSTRACT=all
  1142. # get spamassassin to check emails
  1143. :0fw: .spamassassin.lock
  1144. * < 256000
  1145. | spamc
  1146. # strong spam are discarded
  1147. :0
  1148. * ^X-Spam-Level: \*\*\*\*\*\*
  1149. /dev/null
  1150. # weak spam are kept just in case - clear this out every now and then
  1151. :0
  1152. * ^X-Spam-Level: \*\*\*\*\*
  1153. .0-spam/
  1154. # otherwise, marginal spam goes here for revision
  1155. :0
  1156. * ^X-Spam-Level: \*\*
  1157. .spam/
  1158. #+END_SRC
  1159. Save and exit.
  1160. #+BEGIN_SRC: bash
  1161. su
  1162. editor /usr/bin/filterspam
  1163. #+END_SRC
  1164. Add the following contents:
  1165. #+BEGIN_SRC: bash
  1166. #!/bin/bash
  1167. USERNAME=$1
  1168. MAILDIR=/home/$USERNAME/Maildir/.learn-spam
  1169. if [ ! -d "$MAILDIR" ]; then
  1170. exit
  1171. fi
  1172. for f in `ls $MAILDIR/cur`
  1173. do
  1174. spamc -L spam < "$MAILDIR/cur/$f" > /dev/null
  1175. rm "$MAILDIR/cur/$f"
  1176. done
  1177. for f in `ls $MAILDIR/new`
  1178. do
  1179. spamc -L spam < "$MAILDIR/new/$f" > /dev/null
  1180. rm "$MAILDIR/new/$f"
  1181. done
  1182. #+END_SRC
  1183. Save and exit.
  1184. #+BEGIN_SRC: bash
  1185. editor /usr/bin/filterham
  1186. #+END_SRC
  1187. Add the following contents:
  1188. #+BEGIN_SRC: bash
  1189. #!/bin/bash
  1190. USERNAME=$1
  1191. MAILDIR=/home/$USERNAME/Maildir/.learn-ham
  1192. if [ ! -d "$MAILDIR" ]; then
  1193. exit
  1194. fi
  1195. for f in `ls $MAILDIR/cur`
  1196. do
  1197. spamc -L ham < "$MAILDIR/cur/$f" > /dev/null
  1198. rm "$MAILDIR/cur/$f"
  1199. done
  1200. for f in `ls $MAILDIR/new`
  1201. do
  1202. spamc -L ham < "$MAILDIR/new/$f" > /dev/null
  1203. rm "$MAILDIR/new/$f"
  1204. done
  1205. #+END_SRC
  1206. Save and exit.
  1207. #+BEGIN_SRC: bash
  1208. editor /etc/crontab
  1209. #+END_SRC
  1210. Append the following, replacing *myusername* with your username.
  1211. #+BEGIN_SRC: bash
  1212. */3 * * * * root /usr/bin/timeout 120 /usr/bin/filterspam myusername
  1213. */3 * * * * root /usr/bin/timeout 120 /usr/bin/filterham myusername
  1214. #+END_SRC
  1215. Save and exit.
  1216. #+BEGIN_SRC: bash
  1217. chmod 655 /usr/bin/filterspam /usr/bin/filterham
  1218. service spamassassin restart
  1219. service exim4 restart
  1220. service cron restart
  1221. #+END_SRC
  1222. ** Install Dovecot
  1223. #+BEGIN_VERSE
  1224. /I dreamt last night that I was living in a surveillance state. I woke up and… I’m still in a surveillance state./
  1225. -- Conrad Kramer
  1226. #+END_VERSE
  1227. Install the required packages.
  1228. #+BEGIN_SRC: bash
  1229. aptitude -y install dovecot-common dovecot-imapd
  1230. #+END_SRC
  1231. Edit the configuration file.
  1232. #+BEGIN_SRC: bash
  1233. editor /etc/dovecot/dovecot.conf
  1234. #+END_SRC
  1235. Line 26: change:
  1236. #+BEGIN_SRC: bash
  1237. listen = *
  1238. #+END_SRC
  1239. Save and exit.
  1240. #+BEGIN_SRC: bash
  1241. editor /etc/dovecot/conf.d/10-auth.conf
  1242. #+END_SRC
  1243. Line 9: uncomment and change (allow plain text auth)
  1244. #+BEGIN_SRC: bash
  1245. disable_plaintext_auth = no
  1246. #+END_SRC
  1247. Line 99: add:
  1248. #+BEGIN_SRC: bash
  1249. auth_mechanisms = plain login
  1250. #+END_SRC
  1251. Save and exit.
  1252. #+BEGIN_SRC: bash
  1253. editor /etc/dovecot/conf.d/10-mail.conf
  1254. #+END_SRC
  1255. Line 30: uncomment and add:
  1256. #+BEGIN_SRC: bash
  1257. mail_location = maildir:~/Maildir:LAYOUT=fs
  1258. #+END_SRC
  1259. Save and exit.
  1260. #+BEGIN_SRC: bash
  1261. editor /etc/dovecot/conf.d/10-ssl.conf
  1262. #+END_SRC
  1263. Append the following:
  1264. #+BEGIN_SRC: bash
  1265. ssl_cipher_list = '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:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA'
  1266. #+END_SRC
  1267. Save and exit, then start the dovecot service.
  1268. #+BEGIN_SRC: bash
  1269. service dovecot restart
  1270. #+END_SRC
  1271. ** Create a GPG key
  1272. #+BEGIN_VERSE
  1273. /If privacy is outlawed, only outlaws will have privacy./
  1274. -- Philip Zimmermann
  1275. #+END_VERSE
  1276. *** Initial installation
  1277. Assuming that you are logged in as root, first ensure that GPG is installed and then exit to your user account.
  1278. #+BEGIN_SRC: bash
  1279. apt-get install gnupg
  1280. exit
  1281. #+END_SRC
  1282. Now we will add some settings:
  1283. #+BEGIN_SRC: bash
  1284. mkdir ~/.gnupg
  1285. editor ~/.gnupg/gpg.conf
  1286. #+END_SRC
  1287. The configuration should look like the following. Of particular importance are the default preferences at the end.
  1288. #+BEGIN_SRC: bash
  1289. # Options for GnuPG
  1290. # Copyright 1998, 1999, 2000, 2001, 2002, 2003,
  1291. # 2010 Free Software Foundation, Inc.
  1292. #
  1293. # This file is free software; as a special exception the author gives
  1294. # unlimited permission to copy and/or distribute it, with or without
  1295. # modifications, as long as this notice is preserved.
  1296. #
  1297. # This file is distributed in the hope that it will be useful, but
  1298. # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
  1299. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  1300. #
  1301. # Unless you specify which option file to use (with the command line
  1302. # option "--options filename"), GnuPG uses the file ~/.gnupg/gpg.conf
  1303. # by default.
  1304. #
  1305. # An options file can contain any long options which are available in
  1306. # GnuPG. If the first non white space character of a line is a '#',
  1307. # this line is ignored. Empty lines are also ignored.
  1308. #
  1309. # See the man page for a list of options.
  1310. # Uncomment the following option to get rid of the copyright notice
  1311. #no-greeting
  1312. # If you have more than 1 secret key in your keyring, you may want to
  1313. # uncomment the following option and set your preferred keyid.
  1314. #default-key 621CC013
  1315. # If you do not pass a recipient to gpg, it will ask for one. Using
  1316. # this option you can encrypt to a default key. Key validation will
  1317. # not be done in this case. The second form uses the default key as
  1318. # default recipient.
  1319. #default-recipient some-user-id
  1320. #default-recipient-self
  1321. # Use --encrypt-to to add the specified key as a recipient to all
  1322. # messages. This is useful, for example, when sending mail through a
  1323. # mail client that does not automatically encrypt mail to your key.
  1324. # In the example, this option allows you to read your local copy of
  1325. # encrypted mail that you've sent to others.
  1326. #encrypt-to some-key-id
  1327. # By default GnuPG creates version 4 signatures for data files as
  1328. # specified by OpenPGP. Some earlier (PGP 6, PGP 7) versions of PGP
  1329. # require the older version 3 signatures. Setting this option forces
  1330. # GnuPG to create version 3 signatures.
  1331. #force-v3-sigs
  1332. # Because some mailers change lines starting with "From " to ">From "
  1333. # it is good to handle such lines in a special way when creating
  1334. # cleartext signatures; all other PGP versions do it this way too.
  1335. #no-escape-from-lines
  1336. # If you do not use the Latin-1 (ISO-8859-1) charset, you should tell
  1337. # GnuPG which is the native character set. Please check the man page
  1338. # for supported character sets. This character set is only used for
  1339. # metadata and not for the actual message which does not undergo any
  1340. # translation. Note that future version of GnuPG will change to UTF-8
  1341. # as default character set. In most cases this option is not required
  1342. # as GnuPG is able to figure out the correct charset at runtime.
  1343. #charset utf-8
  1344. # Group names may be defined like this:
  1345. # group mynames = paige 0x12345678 joe patti
  1346. #
  1347. # Any time "mynames" is a recipient (-r or --recipient), it will be
  1348. # expanded to the names "paige", "joe", and "patti", and the key ID
  1349. # "0x12345678". Note there is only one level of expansion - you
  1350. # cannot make an group that points to another group. Note also that
  1351. # if there are spaces in the recipient name, this will appear as two
  1352. # recipients. In these cases it is better to use the key ID.
  1353. #group mynames = paige 0x12345678 joe patti
  1354. # Lock the file only once for the lifetime of a process. If you do
  1355. # not define this, the lock will be obtained and released every time
  1356. # it is needed, which is usually preferable.
  1357. #lock-once
  1358. # GnuPG can send and receive keys to and from a keyserver. These
  1359. # servers can be HKP, email, or LDAP (if GnuPG is built with LDAP
  1360. # support).
  1361. #
  1362. # Example HKP keyserver:
  1363. # hkp://keys.gnupg.net
  1364. # hkp://subkeys.pgp.net
  1365. #
  1366. # Example email keyserver:
  1367. # mailto:pgp-public-keys@keys.pgp.net
  1368. #
  1369. # Example LDAP keyservers:
  1370. # ldap://keyserver.pgp.com
  1371. #
  1372. # Regular URL syntax applies, and you can set an alternate port
  1373. # through the usual method:
  1374. # hkp://keyserver.example.net:22742
  1375. #
  1376. # Most users just set the name and type of their preferred keyserver.
  1377. # Note that most servers (with the notable exception of
  1378. # ldap://keyserver.pgp.com) synchronize changes with each other. Note
  1379. # also that a single server name may actually point to multiple
  1380. # servers via DNS round-robin. hkp://keys.gnupg.net is an example of
  1381. # such a "server", which spreads the load over a number of physical
  1382. # servers. To see the IP address of the server actually used, you may use
  1383. # the "--keyserver-options debug".
  1384. keyserver hkp://keys.gnupg.net
  1385. #keyserver mailto:pgp-public-keys@keys.nl.pgp.net
  1386. #keyserver ldap://keyserver.pgp.com
  1387. # Common options for keyserver functions:
  1388. #
  1389. # include-disabled : when searching, include keys marked as "disabled"
  1390. # on the keyserver (not all keyservers support this).
  1391. #
  1392. # no-include-revoked : when searching, do not include keys marked as
  1393. # "revoked" on the keyserver.
  1394. #
  1395. # verbose : show more information as the keys are fetched.
  1396. # Can be used more than once to increase the amount
  1397. # of information shown.
  1398. #
  1399. # use-temp-files : use temporary files instead of a pipe to talk to the
  1400. # keyserver. Some platforms (Win32 for one) always
  1401. # have this on.
  1402. #
  1403. # keep-temp-files : do not delete temporary files after using them
  1404. # (really only useful for debugging)
  1405. #
  1406. # http-proxy="proxy" : set the proxy to use for HTTP and HKP keyservers.
  1407. # This overrides the "http_proxy" environment variable,
  1408. # if any.
  1409. #
  1410. # auto-key-retrieve : automatically fetch keys as needed from the keyserver
  1411. # when verifying signatures or when importing keys that
  1412. # have been revoked by a revocation key that is not
  1413. # present on the keyring.
  1414. #
  1415. # no-include-attributes : do not include attribute IDs (aka "photo IDs")
  1416. # when sending keys to the keyserver.
  1417. keyserver-options auto-key-retrieve
  1418. # Display photo user IDs in key listings
  1419. # list-options show-photos
  1420. # Display photo user IDs when a signature from a key with a photo is
  1421. # verified
  1422. # verify-options show-photos
  1423. # Use this program to display photo user IDs
  1424. #
  1425. # %i is expanded to a temporary file that contains the photo.
  1426. # %I is the same as %i, but the file isn't deleted afterwards by GnuPG.
  1427. # %k is expanded to the key ID of the key.
  1428. # %K is expanded to the long OpenPGP key ID of the key.
  1429. # %t is expanded to the extension of the image (e.g. "jpg").
  1430. # %T is expanded to the MIME type of the image (e.g. "image/jpeg").
  1431. # %f is expanded to the fingerprint of the key.
  1432. # %% is %, of course.
  1433. #
  1434. # If %i or %I are not present, then the photo is supplied to the
  1435. # viewer on standard input. If your platform supports it, standard
  1436. # input is the best way to do this as it avoids the time and effort in
  1437. # generating and then cleaning up a secure temp file.
  1438. #
  1439. # If no photo-viewer is provided, GnuPG will look for xloadimage, eog,
  1440. # or display (ImageMagick). On Mac OS X and Windows, the default is
  1441. # to use your regular JPEG image viewer.
  1442. #
  1443. # Some other viewers:
  1444. # photo-viewer "qiv %i"
  1445. # photo-viewer "ee %i"
  1446. #
  1447. # This one saves a copy of the photo ID in your home directory:
  1448. # photo-viewer "cat > ~/photoid-for-key-%k.%t"
  1449. #
  1450. # Use your MIME handler to view photos:
  1451. # photo-viewer "metamail -q -d -b -c %T -s 'KeyID 0x%k' -f GnuPG"
  1452. # Passphrase agent
  1453. #
  1454. # We support the old experimental passphrase agent protocol as well as
  1455. # the new Assuan based one (currently available in the "newpg" package
  1456. # at ftp.gnupg.org/gcrypt/alpha/aegypten/). To make use of the agent,
  1457. # you have to run an agent as daemon and use the option
  1458. #
  1459. # use-agent
  1460. #
  1461. # which tries to use the agent but will fallback to the regular mode
  1462. # if there is a problem connecting to the agent. The normal way to
  1463. # locate the agent is by looking at the environment variable
  1464. # GPG_AGENT_INFO which should have been set during gpg-agent startup.
  1465. # In certain situations the use of this variable is not possible, thus
  1466. # the option
  1467. #
  1468. # --gpg-agent-info=<path>:<pid>:1
  1469. #
  1470. # may be used to override it.
  1471. # Automatic key location
  1472. #
  1473. # GnuPG can automatically locate and retrieve keys as needed using the
  1474. # auto-key-locate option. This happens when encrypting to an email
  1475. # address (in the "user@example.com" form), and there are no
  1476. # user@example.com keys on the local keyring. This option takes the
  1477. # following arguments, in the order they are to be tried:
  1478. #
  1479. # cert = locate a key using DNS CERT, as specified in RFC-4398.
  1480. # GnuPG can handle both the PGP (key) and IPGP (URL + fingerprint)
  1481. # CERT methods.
  1482. #
  1483. # pka = locate a key using DNS PKA.
  1484. #
  1485. # ldap = locate a key using the PGP Universal method of checking
  1486. # "ldap://keys.(thedomain)". For example, encrypting to
  1487. # user@example.com will check ldap://keys.example.com.
  1488. #
  1489. # keyserver = locate a key using whatever keyserver is defined using
  1490. # the keyserver option.
  1491. #
  1492. # You may also list arbitrary keyservers here by URL.
  1493. #
  1494. # Try CERT, then PKA, then LDAP, then hkp://subkeys.net:
  1495. #auto-key-locate cert pka ldap hkp://subkeys.pgp.net
  1496. # default preferences
  1497. personal-digest-preferences SHA256
  1498. cert-digest-algo SHA256
  1499. default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
  1500. #+END_SRC
  1501. Save and exit.
  1502. *** If you have an existing key
  1503. #+BEGIN_SRC: bash
  1504. gpg --import ~/public_key.txt
  1505. gpg --allow-secret-key-import --import ~/private_key.txt
  1506. shred -zu ~/private_key.txt
  1507. #+END_SRC
  1508. 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.
  1509. #+BEGIN_SRC: bash
  1510. export MYGPGKEYID=keyID
  1511. gpg --edit-key $MYGPGKEYID
  1512. setpref SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
  1513. save
  1514. gpg --send-keys $MYGPGKEYID
  1515. #+END_SRC
  1516. *** To create a new key
  1517. Generate a key with the following command:
  1518. #+BEGIN_SRC: bash
  1519. gpg --gen-key
  1520. #+END_SRC
  1521. You can find your GPG key ID by entering:
  1522. #+BEGIN_SRC: bash
  1523. gpg --list-keys
  1524. #+END_SRC
  1525. The key ID is the second part of the string of numbers and letters. So for example in:
  1526. #+BEGIN_SRC: bash
  1527. pub 4096R/EA982E38 2012-05-20
  1528. #+END_SRC
  1529. the key ID is EA982E38. Now send your public key to a server so that others can find it.
  1530. #+BEGIN_SRC: bash
  1531. gpg --send-keys $MYGPGKEYID
  1532. #+END_SRC
  1533. *** root settings
  1534. 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:
  1535. #+BEGIN_SRC: bash
  1536. su
  1537. cp -r /home/myusername/.gnupg ~/
  1538. chown -R root:root ~/.gnupg
  1539. #+END_SRC
  1540. ** Protect processes
  1541. Because the BBB has limited RAM some processes may occasionally be automatically killed if physical memory availability is getting too low. The way in which processes are chosen to be sacrificed is not particularly intelligent, and so can result in vital systems being stopped. To try to prevent that from ever happening the following script can be used, which should ensure that at a minimum ssh, email and mysql keep running.
  1542. #+BEGIN_SRC: bash
  1543. editor /usr/bin/protectprocesses
  1544. #+END_SRC
  1545. Add the following:
  1546. #+BEGIN_SRC: bash
  1547. #!/bin/bash
  1548. declare -a protect=('/usr/sbin/sshd' '/usr/sbin/mysqld --basedir=/usr' '/bin/sh /usr/bin/mysqld_safe' '/usr/sbin/exim4')
  1549. for p in "${protect[@]}"
  1550. do
  1551. OOM_PROC_ID=$(ps aux | grep '$p' | grep -v grep | head -n 1 | awk -F ' ' '{print $2}')
  1552. if [ ! -z "$OOM_PROC_ID" ]; then
  1553. echo -1000 >/proc/$OOM_PROC_ID/oom_score_adj
  1554. echo -17 >/proc/$OOM_PROC_ID/oom_adj
  1555. fi
  1556. done
  1557. #+END_SRC
  1558. Save and exit, then edit the cron jobs:
  1559. #+BEGIN_SRC: bash
  1560. editor /etc/crontab
  1561. #+END_SRC
  1562. And add the line:
  1563. #+BEGIN_SRC: bash
  1564. */1 * * * * root /usr/bin/timeout 30 /usr/bin/protectprocesses
  1565. #+END_SRC
  1566. Then save and exit and restart cron.
  1567. #+BEGIN_SRC: bash
  1568. chmod +x /usr/bin/protectprocesses
  1569. service cron restart
  1570. #+END_SRC
  1571. Here cron is used so that if we stop one of the relevant processes and then restart it then its oom priority will be reassigned again
  1572. .
  1573. ** Setting up a web site
  1574. #+BEGIN_VERSE
  1575. /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./
  1576. -- Tim Berners-Lee
  1577. #+END_VERSE
  1578. Edit the apache configuration so that it doesn't run out of memory if there are a lot of connections.
  1579. #+BEGIN_SRC: bash
  1580. su
  1581. editor /etc/apache2/apache2.conf
  1582. #+END_SRC
  1583. Search for MaxClients and replace the value with 6. As an example the settings should look something like this:
  1584. #+BEGIN_SRC: bash
  1585. Timeout 30
  1586. KeepAlive On
  1587. MaxKeepAliveRequests 5
  1588. KeepAliveTimeout 10
  1589. <IfModule mpm_prefork_module>
  1590. StartServers 1
  1591. MinSpareServers 1
  1592. MaxSpareServers 3
  1593. MaxClients 10
  1594. MaxRequestsPerChild 3000
  1595. </IfModule>
  1596. <IfModule mpm_worker_module>
  1597. StartServers 1
  1598. MinSpareThreads 5
  1599. MaxSpareThreads 15
  1600. ThreadLimit 25
  1601. ThreadsPerChild 5
  1602. MaxClients 25
  1603. MaxRequestsPerChild 200
  1604. </IfModule>
  1605. <IfModule mpm_event_module>
  1606. StartServers 1
  1607. MinSpareThreads 5
  1608. MaxSpareThreads 15
  1609. ThreadLimit 25
  1610. ThreadsPerChild 5
  1611. MaxClients 25
  1612. MaxRequestsPerChild 200
  1613. </IfModule>
  1614. #+END_SRC
  1615. Also append the following:
  1616. #+BEGIN_SRC: bash
  1617. ServerSignature Off
  1618. ServerTokens Prod
  1619. #+END_SRC
  1620. Then save and exit. Install some extra security.
  1621. #+BEGIN_SRC: bash
  1622. apt-get install libapache2-modsecurity
  1623. apt-get install libapache2-mod-evasive
  1624. #+END_SRC
  1625. In the examples below replace /mydomainname.com/ with your own domain name.
  1626. #+BEGIN_SRC: bash
  1627. export HOSTNAME=mydomainname.com
  1628. mkdir /var/www/$HOSTNAME
  1629. mkdir /var/www/$HOSTNAME/htdocs
  1630. editor /etc/apache2/sites-available/$HOSTNAME
  1631. #+END_SRC
  1632. The Apache configuration for the site should look something like the following. Replace /mydonainname.com/ with the site domain name.
  1633. #+BEGIN_SRC: bash
  1634. <VirtualHost *:80>
  1635. ServerAdmin myusername@mydomainname.com
  1636. ServerName mydomainname.com
  1637. DocumentRoot /var/www/mydomainname.com/htdocs
  1638. <Directory />
  1639. Options FollowSymLinks
  1640. AllowOverride All
  1641. </Directory>
  1642. <Directory /var/www/mydomainname.com/htdocs/>
  1643. Options All
  1644. AllowOverride All
  1645. Order allow,deny
  1646. allow from all
  1647. LimitRequestBody 128000
  1648. </Directory>
  1649. # Don't serve .php~ or .php# files created by emacs
  1650. <Files ~ "(^#.*#|~|\.sw[op])$">
  1651. Order allow,deny
  1652. Deny from all
  1653. </Files>
  1654. <IfModule headers_module>
  1655. Header set X-Content-Type-Options nosniff
  1656. Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate, private"
  1657. Header set Pragma no-cache
  1658. </IfModule>
  1659. <Files .htaccess>
  1660. deny from all
  1661. </Files>
  1662. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  1663. <Directory "/usr/lib/cgi-bin">
  1664. AllowOverride All
  1665. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  1666. Order allow,deny
  1667. Allow from all
  1668. LimitRequestBody 128000
  1669. </Directory>
  1670. ErrorLog ${APACHE_LOG_DIR}/error.log
  1671. # Possible values include: debug, info, notice, warn, error, crit,
  1672. # alert, emerg.
  1673. LogLevel error
  1674. CustomLog ${APACHE_LOG_DIR}/access.log combined
  1675. </VirtualHost>
  1676. <IfModule mod_ssl.c>
  1677. <VirtualHost *:443>
  1678. ServerAdmin myusername@mydomainname.com
  1679. ServerName mydomainname.com
  1680. DocumentRoot /var/www/mydomainname.com/htdocs
  1681. <Directory />
  1682. Options FollowSymLinks
  1683. AllowOverride All
  1684. </Directory>
  1685. <Directory /var/www/mydomainname.com/htdocs/>
  1686. Options All
  1687. AllowOverride All
  1688. Order allow,deny
  1689. allow from all
  1690. LimitRequestBody 128000
  1691. </Directory>
  1692. # Don't serve .php~ or .php# files created by emacs
  1693. <Files ~ "(^#.*#|~|\.sw[op])$">
  1694. Order allow,deny
  1695. Deny from all
  1696. </Files>
  1697. <IfModule headers_module>
  1698. Header set X-Content-Type-Options nosniff
  1699. Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate, private"
  1700. Header set Pragma no-cache
  1701. </IfModule>
  1702. <Files .htaccess>
  1703. deny from all
  1704. </Files>
  1705. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  1706. <Directory "/usr/lib/cgi-bin">
  1707. AllowOverride All
  1708. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  1709. Order allow,deny
  1710. Allow from all
  1711. LimitRequestBody 128000
  1712. </Directory>
  1713. ErrorLog ${APACHE_LOG_DIR}/error.log
  1714. # Possible values include: debug, info, notice, warn, error, crit,
  1715. # alert, emerg.
  1716. LogLevel error
  1717. CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
  1718. # SSL Engine Switch:
  1719. # Enable/Disable SSL for this virtual host.
  1720. SSLEngine on
  1721. # A self-signed certificate
  1722. SSLCertificateFile /etc/ssl/certs/mydomainname.com.crt
  1723. SSLCertificateKeyFile /etc/ssl/private/mydomainname.com.key
  1724. # Options based on bettercrypto.org
  1725. SSLProtocol All -SSLv2 -SSLv3
  1726. SSLHonorCipherOrder On
  1727. SSLCompression off
  1728. 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
  1729. # Add six earth month HSTS header for all users ...
  1730. Header add Strict-Transport-Security "max-age=15768000"
  1731. # If you want to protect all subdomains , use the following header
  1732. # ALL subdomains HAVE TO support https if you use this !
  1733. # Strict-Transport-Security: max-age=15768000 ; includeSubDomains
  1734. # SSL Engine Options:
  1735. # Set various options for the SSL engine.
  1736. # o FakeBasicAuth:
  1737. # Translate the client X.509 into a Basic Authorisation. This means that
  1738. # the standard Auth/DBMAuth methods can be used for access control. The
  1739. # user name is the `one line' version of the client's X.509 certificate.
  1740. # Note that no password is obtained from the user. Every entry in the user
  1741. # file needs this password: `xxj31ZMTZzkVA'.
  1742. # o ExportCertData:
  1743. # This exports two additional environment variables: SSL_CLIENT_CERT and
  1744. # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
  1745. # server (always existing) and the client (only existing when client
  1746. # authentication is used). This can be used to import the certificates
  1747. # into CGI scripts.
  1748. # o StdEnvVars:
  1749. # This exports the standard SSL/TLS related `SSL_*' environment variables.
  1750. # Per default this exportation is switched off for performance reasons,
  1751. # because the extraction step is an expensive operation and is usually
  1752. # useless for serving static content. So one usually enables the
  1753. # exportation for CGI and SSI requests only.
  1754. # o StrictRequire:
  1755. # This denies access when "SSLRequireSSL" or "SSLRequire" applied even
  1756. # under a "Satisfy any" situation, i.e. when it applies access is denied
  1757. # and no other module can change it.
  1758. # o OptRenegotiate:
  1759. # This enables optimized SSL connection renegotiation handling when SSL
  1760. # directives are used in per-directory context.
  1761. #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
  1762. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  1763. SSLOptions +StdEnvVars
  1764. </FilesMatch>
  1765. <Directory /usr/lib/cgi-bin>
  1766. SSLOptions +StdEnvVars
  1767. </Directory>
  1768. # SSL Protocol Adjustments:
  1769. # The safe and default but still SSL/TLS standard compliant shutdown
  1770. # approach is that mod_ssl sends the close notify alert but doesn't wait for
  1771. # the close notify alert from client. When you need a different shutdown
  1772. # approach you can use one of the following variables:
  1773. # o ssl-unclean-shutdown:
  1774. # This forces an unclean shutdown when the connection is closed, i.e. no
  1775. # SSL close notify alert is send or allowed to received. This violates
  1776. # the SSL/TLS standard but is needed for some brain-dead browsers. Use
  1777. # this when you receive I/O errors because of the standard approach where
  1778. # mod_ssl sends the close notify alert.
  1779. # o ssl-accurate-shutdown:
  1780. # This forces an accurate shutdown when the connection is closed, i.e. a
  1781. # SSL close notify alert is send and mod_ssl waits for the close notify
  1782. # alert of the client. This is 100% SSL/TLS standard compliant, but in
  1783. # practice often causes hanging connections with brain-dead browsers. Use
  1784. # this only for browsers where you know that their SSL implementation
  1785. # works correctly.
  1786. # Notice: Most problems of broken clients are also related to the HTTP
  1787. # keep-alive facility, so you usually additionally want to disable
  1788. # keep-alive for those clients, too. Use variable "nokeepalive" for this.
  1789. # Similarly, one has to force some clients to use HTTP/1.0 to workaround
  1790. # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
  1791. # "force-response-1.0" for this.
  1792. BrowserMatch "MSIE [2-6]" \
  1793. nokeepalive ssl-unclean-shutdown \
  1794. downgrade-1.0 force-response-1.0
  1795. # MSIE 7 and newer should be able to use keepalive
  1796. BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  1797. </VirtualHost>
  1798. </IfModule>
  1799. #+END_SRC
  1800. Then to enable the site:
  1801. #+BEGIN_SRC: bash
  1802. a2ensite
  1803. a2dissite default
  1804. a2dissite default-ssl
  1805. a2enmod rewrite
  1806. a2enmod headers
  1807. #+END_SRC
  1808. Ensure that "NameVirtualHost *:443" is added to /etc/apache2/ports.conf. It should look something like the following:
  1809. #+BEGIN_SRC: bash
  1810. NameVirtualHost *:80
  1811. Listen 80
  1812. <IfModule mod_ssl.c>
  1813. NameVirtualHost *:443
  1814. Listen 443
  1815. </IfModule>
  1816. <IfModule mod_gnutls.c>
  1817. NameVirtualHost *:443
  1818. Listen 443
  1819. </IfModule>
  1820. #+END_SRC
  1821. Create a self-signed certificate. The passphrase isn't important and will be removed, so make it easy (such as "password").
  1822. #+BEGIN_SRC: bash
  1823. editor /usr/bin/makecert
  1824. #+END_SRC
  1825. Enter the following:
  1826. #+BEGIN_SRC: bash
  1827. #!/bin/bash
  1828. HOSTNAME=$1
  1829. openssl genrsa -des3 -out $HOSTNAME.key 1024
  1830. openssl req -new -x509 -nodes -sha1 -days 3650 -key $HOSTNAME.key -out $HOSTNAME.crt
  1831. openssl rsa -in $HOSTNAME.key -out $HOSTNAME.new.key
  1832. cp $HOSTNAME.new.key $HOSTNAME.key
  1833. rm $HOSTNAME.new.key
  1834. cp $HOSTNAME.key /etc/ssl/private
  1835. chmod 400 /etc/ssl/private/$HOSTNAME.key
  1836. cp $HOSTNAME.crt /etc/ssl/certs
  1837. shred -zu $HOSTNAME.key $HOSTNAME.crt
  1838. a2enmod ssl
  1839. service apache2 restart
  1840. #+END_SRC
  1841. Save and exit.
  1842. #+BEGIN_SRC: bash
  1843. chmod +x /usr/bin/makecert
  1844. makecert mydomainname.com
  1845. #+END_SRC
  1846. Enter some trivial password for the key file, such as "password". The password will be removed as part of the /makecert/ script which you just created. 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.
  1847. 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.
  1848. Also limit the amount of memory which any php scripts can use.
  1849. #+BEGIN_SRC: bash
  1850. editor /etc/php5/apache2/php.ini
  1851. #+END_SRC
  1852. Set the following:
  1853. #+BEGIN_SRC: bash
  1854. memory_limit = 32M
  1855. #+END_SRC
  1856. Save and exit. Also edit */etc/php5/cli/php.ini* and set /memory_limit/ to the same value. This should prevent any rogue scripts from crashing the system.
  1857. ** Accessing your Email
  1858. #+BEGIN_VERSE
  1859. /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./
  1860. -- Article on the "Google-Military-Surveillance Complex" by Yasha Levine
  1861. #+END_VERSE
  1862. *** Mutt email client
  1863. #+BEGIN_SRC: bash
  1864. apt-get install mutt-patched lynx abook
  1865. exit
  1866. mkdir ~/.mutt
  1867. echo "text/html; lynx -dump -width=78 -nolist %s | sed ‘s/^ //’; copiousoutput; needsterminal; nametemplate=%s.html" > ~/.mutt/mailcap
  1868. su
  1869. editor /etc/Muttrc
  1870. #+END_SRC
  1871. Append the following:
  1872. #+BEGIN_SRC: bash
  1873. set mbox_type=Maildir
  1874. set folder="~/Maildir"
  1875. set mask="!^\\.[^.]"
  1876. set mbox="~/Maildir"
  1877. set record="+Sent"
  1878. set postponed="+Drafts"
  1879. set trash="+Trash"
  1880. set spoolfile="~/Maildir"
  1881. auto_view text/x-vcard text/html text/enriched
  1882. set editor="emacs"
  1883. set header_cache="+.cache"
  1884. macro index S "<tag-prefix><save-message>=.learn-spam<enter>" "move to learn-spam"
  1885. macro pager S "<save-message>=.learn-spam<enter>" "move to learn-spam"
  1886. macro index H "<tag-prefix><copy-message>=.learn-ham<enter>" "copy to learn-ham"
  1887. macro pager H "<copy-message>=.learn-ham<enter>" "copy to learn-ham"
  1888. # set up the sidebar
  1889. set sidebar_width=12
  1890. set sidebar_visible=yes
  1891. set sidebar_delim='|'
  1892. set sidebar_sort=yes
  1893. set rfc2047_parameters
  1894. # Show inbox and sent items
  1895. mailboxes = =Sent
  1896. # Alter these colours as needed for maximum bling
  1897. color sidebar_new yellow default
  1898. color normal white default
  1899. color hdrdefault brightcyan default
  1900. color signature green default
  1901. color attachment brightyellow default
  1902. color quoted green default
  1903. color quoted1 white default
  1904. color tilde blue default
  1905. # ctrl-n, ctrl-p to select next, prev folder
  1906. # ctrl-o to open selected folder
  1907. bind index \Cp sidebar-prev
  1908. bind index \Cn sidebar-next
  1909. bind index \Co sidebar-open
  1910. bind pager \Cp sidebar-prev
  1911. bind pager \Cn sidebar-next
  1912. bind pager \Co sidebar-open
  1913. # ctrl-b toggles sidebar visibility
  1914. macro index,pager \Cb '<enter-command>toggle sidebar_visible<enter><redraw-screen>' "toggle sidebar"
  1915. # esc-m Mark new messages as read
  1916. macro index <esc>m "T~N<enter>;WNT~O<enter>;WO\CT~T<enter>" "mark all messages read"
  1917. # Collapsing threads
  1918. macro index [ "<collapse-thread>" "collapse/uncollapse thread"
  1919. macro index ] "<collapse-all>" "collapse/uncollapse all threads"
  1920. # threads containing new messages
  1921. uncolor index "~(~N)"
  1922. color index brightblue default "~(~N)"
  1923. # new messages themselves
  1924. uncolor index "~N"
  1925. color index brightyellow default "~N"
  1926. # GPG/PGP integration
  1927. # this set the number of seconds to keep in memory the passphrase used to encrypt/sign
  1928. set pgp_timeout=60
  1929. # automatically sign and encrypt
  1930. set pgp_autosign # autosign all outgoing mails
  1931. set pgp_replyencrypt # autocrypt replies to crypted
  1932. set pgp_replysign # autosign replies to signed
  1933. set pgp_auto_decode=yes # decode attachments
  1934. #+END_SRC
  1935. Save and exit.
  1936. #+BEGIN_SRC: bash
  1937. editor /etc/mail/spamassassin/local.cf
  1938. #+END_SRC
  1939. Uncomment *use_bayes*, *bayes_auto_learn*
  1940. Save and exit, then run:
  1941. #+BEGIN_SRC: bash
  1942. service spamassassin restart
  1943. #+END_SRC
  1944. Now to add an address book:
  1945. #+BEGIN_SRC: bash
  1946. editor ~/.muttrc
  1947. #+END_SRC
  1948. Append the following:
  1949. #+BEGIN_SRC: bash
  1950. set alias_file=~/.mutt-alias
  1951. source ~/.mutt-alias
  1952. set query_command= "abook --mutt-query '%s'"
  1953. macro index,pager A "<pipe-message>abook --add-email-quiet<return>" "add the sender address to abook"
  1954. #+END_SRC
  1955. Then save and exit.
  1956. #+BEGIN_SRC: bash
  1957. touch ~/.mutt-alias
  1958. #+END_SRC
  1959. 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.
  1960. 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.
  1961. Some useful keys to know are:
  1962. | ESC / | Search for text within message contents |
  1963. | "/" | Search for text within headers |
  1964. | * | Move to the last message |
  1965. | TAB | Move to the next unread message |
  1966. | d | Delete a message |
  1967. | u | Undelete a mail which is pending deletion |
  1968. | $ | Delete all messages selected and check for new messages |
  1969. | a | Add to the address book |
  1970. | m | Send a new mail |
  1971. | ESC-m | Mark all messages as having been read |
  1972. | S | Mark a message as spam |
  1973. | H | Mark a message as ham |
  1974. | CTRL-b | Toggle side bar on/off |
  1975. | CTRL-n | Next mailbox (on side bar) |
  1976. | CTRL-p | Previous mailbox (on side bar) |
  1977. | CTRL-o | Open mailbox (on side bar) |
  1978. | ] | Expand or collapse all threads |
  1979. | [ | Expand of collapse the current thread |
  1980. | CTRL-k | Import a PGP/GPG public key |
  1981. One of the most common things which you might wish to do is to send an email. To do this first press /m/ to create a new message. Enter the address to send to and the subject, then after a few seconds the Emacs editor will appear with a blank document. Type your email then press /CTRL-x CTRL-s/ to save it and /CTRL-x CTRL-c/ to exit. You will then see a summary of the email to be sent out. Press /y/ to send it and then enter your GPG key passphrase (the one you gave when creating a PGP/GPG key). The purpose of that is to add a signature which is a strong proof that the email was written by you and not by someone else.
  1982. *** K9 Android client
  1983. #+BEGIN_VERSE
  1984. /The surveillance state is robust. It is robust politically, legally, and technically./
  1985. -- Bruce Schneier
  1986. #+END_VERSE
  1987. **** Incoming server settings
  1988. * Select settings/account settings
  1989. * Select Fetching mail/incoming server
  1990. * Enter your username and password
  1991. * IMAP server should be your domain name
  1992. * Security: SSL/TLS (always)
  1993. * Authentication: Plain
  1994. * Port: 993
  1995. **** Outgoing (SMTP) server settings
  1996. * Select settings/account settings
  1997. * Select Sending mail/outgoing server
  1998. * Set SMTP server to your domain name
  1999. * Set Security to SSL/TLS (always)
  2000. * Set port to 465
  2001. * Set authentication to PLAIN
  2002. * Enter your username and password
  2003. * Accept the SSL certificate
  2004. **** Folders
  2005. 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*.
  2006. If your folder still doesn't show up then press the *menu button*, select *show folders* and select *all folders*.
  2007. *** Webmail
  2008. #+BEGIN_VERSE
  2009. /Most of the information extracted is "content", such as recordings of phone calls or the substance of email messages./
  2010. -- From a 2013 Guardian article on GCHQ/NSA bulk internet data interception.
  2011. #+END_VERSE
  2012. 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.
  2013. Install dependencies.
  2014. #+BEGIN_SRC: bash
  2015. apt-get install libapache2-mod-authz-unixgroup
  2016. #+END_SRC
  2017. Create a mysql database, specifying a password which should be a long random string generated with a password manager such as KeepassX.
  2018. #+BEGIN_SRC: bash
  2019. mysql -u root -p
  2020. create database roundcubemail;
  2021. CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'roundcubepassword';
  2022. GRANT ALL PRIVILEGES ON roundcubemail.* TO 'roundcube'@'localhost';
  2023. quit
  2024. #+END_SRC
  2025. Download roundcube.
  2026. #+BEGIN_SRC: bash
  2027. cd /tmp
  2028. wget http://freedombone.uk.to/roundcubemail.tar.gz
  2029. #+END_SRC
  2030. Verify it.
  2031. #+BEGIN_SRC: bash
  2032. sha256sum roundcubemail.tar.gz
  2033. e8a311b22a8e1f70abb72ed9551cc9233cf6c5221f1eebf1ae64974117e3148b roundcubemail.tar.gz
  2034. #+END_SRC
  2035. Extract the files.
  2036. #+BEGIN_SRC: bash
  2037. tar -xzvf roundcubemail.tar.gz
  2038. export HOSTNAME=mydomainname.com
  2039. cp -r roundcubemail-* /var/www/$HOSTNAME/htdocs/mail
  2040. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/mail/temp
  2041. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/mail/logs
  2042. rm /var/www/$HOSTNAME/htdocs/mail/.htaccess
  2043. #+END_SRC
  2044. Edit your web site configuration.
  2045. #+BEGIN_SRC: bash
  2046. editor /etc/apache2/sites-available/$HOSTNAME
  2047. #+END_SRC
  2048. Within the 80 VirtualHost section add the following:
  2049. #+BEGIN_SRC: bash
  2050. <Directory /var/www/mydomainname.com/htdocs/mail>
  2051. deny from all
  2052. </Directory>
  2053. #+END_SRC
  2054. Within the 443 VirtualHost section add the following:
  2055. #+BEGIN_SRC: bash
  2056. <Directory /var/www/mydomainname.com/htdocs/mail>
  2057. Options Indexes FollowSymLinks MultiViews
  2058. AllowOverride All
  2059. Order allow,deny
  2060. allow from all
  2061. </Directory>
  2062. #+END_SRC
  2063. Save and exit, then restart Apache.
  2064. #+BEGIN_SRC: bash
  2065. service apache2 restart
  2066. #+END_SRC
  2067. Now with a browser visit https://mydomainname.com/mail/installer. Scroll down and click "next". Give your webmail site a product name.
  2068. The *spellcheck_engine* option being limited to Google is slightly concerning in terms of privacy and security, but seems not to be implemented.
  2069. Change the *database password* to the password you gave when creating the MySql database above.
  2070. Set *smtp_port* to 465.
  2071. Click *create config*
  2072. Click download to download the file.
  2073. The config file which you downloaded should contain the following:
  2074. #+BEGIN_SRC: bash
  2075. $config['default_host'] = 'localhost';
  2076. $config['smtp_port'] = 465;
  2077. $config['username_domain'] = '';
  2078. #+END_SRC
  2079. In a terminal on your local machine (not logged into the BBB):
  2080. #+BEGIN_SRC: bash
  2081. cd ~/Downloads
  2082. scp config.inc.php myusername@mydomainname.com:/home/myusername
  2083. #+END_SRC
  2084. Then in a terminal ssh'd into the BBB:
  2085. #+BEGIN_SRC: bash
  2086. mv /home/myusername/config.inc.php /var/www/$HOSTNAME/htdocs/mail/config
  2087. chmod 755 /var/www/$HOSTNAME/htdocs/mail/config/config.inc.php
  2088. #+END_SRC
  2089. Click *continue*.
  2090. Click *initialize database*.
  2091. Under *Test SMTP config* you can use a [[mailinator.com]] address to check that mail can be sent.
  2092. Now we can delete the installer.
  2093. #+BEGIN_SRC: bash
  2094. rm -rf /var/www/$HOSTNAME/htdocs/mail/installer
  2095. #+END_SRC
  2096. Now with a browser navigate to https://mydomainname.com/mail and log in.
  2097. 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.
  2098. 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.
  2099. *** Thunderbird
  2100. #+BEGIN_VERSE
  2101. /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./
  2102. -- Brian Spector, on the shutting down of the PrivateSky encrypted email service
  2103. #+END_VERSE
  2104. 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.
  2105. The following instructions should be carried out on the client machines (laptop, etc), not on the BBB itself.
  2106. **** Initial setup
  2107. Install *Thunderbird* and *Enigmail*. How you do this just depends upon your distro and software manager or "app store".
  2108. Open Thinderbird
  2109. Select "*Skip this and use existing email*"
  2110. Enter your name, email address (myusername@mydomainname.com) and the password for your user (the one from [[Add a user]]).
  2111. You'll get a message saying "/Thunderbird failed to find the settings/"
  2112. The settings should be as follows, substituting /mydomainname.com/ for your domain name and /myusername/ for the username given previously in [[Add a user]].
  2113. * Incoming: IMAP, mydomainname.com, 993, SSL/TLS, Normal Password
  2114. * Outgoing: SMTP, mydomainname.com, 465, SSL/TLS, Normal Password
  2115. * Username: myusername
  2116. Click *Done*.
  2117. Click *Get Certificate* and make sure "*permanently store this exception*" is selected", then click *Store Security Exception*.
  2118. 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.
  2119. Select "*Yes, I want to sign all of my email*"
  2120. Select "*No, I will create per-recipient rules*"
  2121. Select "*yes*" to change default settings.
  2122. **** If you have existing GPG key
  2123. Export your GPG public and private keys.
  2124. #+BEGIN_SRC: bash
  2125. gpg --output ~/public_key.txt --armor --export KEY_ID
  2126. gpg --output ~/private_key.txt --armor --export-secret-key KEY_ID
  2127. #+END_SRC
  2128. Select "*I have existing public and private keys*".
  2129. Select your public and private GPG exported key files.
  2130. Select the account which you want to use and click *Next*, *Next* and *Finish*.
  2131. Remove your exported key files.
  2132. #+BEGIN_SRC: bash
  2133. shred -zu ~/public_key.txt
  2134. shred -zu ~/private_key.txt
  2135. #+END_SRC
  2136. **** If you don't have any existing GPG or PGP key
  2137. Select "*I want to create a new key pair*"
  2138. Enter a passphrase and click *Next* a couple of times.
  2139. Click *Generate Certificate* to generate a revocation certificate.
  2140. Enter the passphrase which you gave previously.
  2141. Click *Finish*
  2142. 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.
  2143. 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.
  2144. **** Using for the first time
  2145. Click on the Thunderbird menu, which looks like three horizontal bars on the right hand side.
  2146. Hover over *preferences* and then *Account settings*.
  2147. Select *Synchronization & Storage*.
  2148. Make sure that *Keep messages for this account on this computer* is unticked, then click *Ok*.
  2149. Click on *Inbox*. Depending upon how much email you have it may take a while to import the subject lines.
  2150. Note that when sending an email for the first time you will also need to accept the SSL certificate.
  2151. 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.
  2152. **** Making folders visible
  2153. 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:
  2154. *Menu*, hover over *Preferences*, select *Account Settings*, select *Server Settings* then click on the *Advanced* button.
  2155. 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.
  2156. ** Create Email folders and rules
  2157. #+BEGIN_VERSE
  2158. /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./
  2159. -- Aral Balkan
  2160. #+END_VERSE
  2161. *** Rules for mailing lists
  2162. 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.
  2163. We can make a script to make adding mailing list rules easy:
  2164. #+BEGIN_SRC: bash
  2165. editor /usr/bin/mailinglistrule
  2166. #+END_SRC
  2167. Add the following:
  2168. #+BEGIN_SRC: bash
  2169. #!/bin/bash
  2170. MYUSERNAME=$1
  2171. MAILINGLIST=$2
  2172. SUBJECTTAG=$3
  2173. MUTTRC=/home/$MYUSERNAME/.muttrc
  2174. PM=/home/$MYUSERNAME/.procmailrc
  2175. LISTDIR=/home/$MYUSERNAME/Maildir/$MAILINGLIST
  2176. if [ ! -d "$LISTDIR" ]; then
  2177. mkdir -m 700 $LISTDIR
  2178. mkdir -m 700 $LISTDIR/tmp
  2179. mkdir -m 700 $LISTDIR/new
  2180. mkdir -m 700 $LISTDIR/cur
  2181. fi
  2182. chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR
  2183. echo "" >> $PM
  2184. echo ":0" >> $PM
  2185. echo " * ^Subject:.*()\[$SUBJECTTAG\]" >> $PM
  2186. echo "$LISTDIR/new" >> $PM
  2187. chown $MYUSERNAME:$MYUSERNAME $PM
  2188. if [ ! -f "$MUTTRC" ]; then
  2189. cp /etc/Muttrc $MUTTRC
  2190. chown $MYUSERNAME:$MYUSERNAME $MUTTRC
  2191. fi
  2192. PROCMAILLOG=/home/$MYUSERNAME/log
  2193. if [ ! -d $PROCMAILLOG ]; then
  2194. mkdir $PROCMAILLOG
  2195. chown -R $MYUSERNAME:$MYUSERNAME $PROCMAILLOG
  2196. fi
  2197. #+END_SRC
  2198. Save and exit, then make the script executable.
  2199. #+BEGIN_SRC: bash
  2200. chmod +x /usr/bin/mailinglistrule
  2201. #+END_SRC
  2202. 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.
  2203. #+BEGIN_SRC: bash
  2204. mailinglistrule [myusername] [mailinglistname] [subjecttag]
  2205. #+END_SRC
  2206. Repeat this command for as many mailing lists as you need. Then edit your local Mutt configuration.
  2207. #+BEGIN_SRC: bash
  2208. editor /home/myusername/.muttrc
  2209. #+END_SRC
  2210. Search for the *mailboxes* variable and add entries for the mailing lists you just created. For example:
  2211. #+BEGIN_SRC: bash
  2212. mailboxes = =Sent =mailinglistname
  2213. #+END_SRC
  2214. Then save and exit.
  2215. *** Rules for specific email addresses
  2216. You can also make a script which will allow you to move mail from specific email addresses to a folder.
  2217. #+BEGIN_SRC: bash
  2218. editor /usr/bin/emailrule
  2219. #+END_SRC
  2220. Add the following:
  2221. #+BEGIN_SRC: bash
  2222. #!/bin/bash
  2223. MYUSERNAME=$1
  2224. EMAILADDRESS=$2
  2225. MAILINGLIST=$3
  2226. MUTTRC=/home/$MYUSERNAME/.muttrc
  2227. PM=/home/$MYUSERNAME/.procmailrc
  2228. LISTDIR=/home/$MYUSERNAME/Maildir/$MAILINGLIST
  2229. if [ ! -d "$LISTDIR" ]; then
  2230. mkdir -m 700 $LISTDIR
  2231. mkdir -m 700 $LISTDIR/tmp
  2232. mkdir -m 700 $LISTDIR/new
  2233. mkdir -m 700 $LISTDIR/cur
  2234. fi
  2235. chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR
  2236. echo "" >> $PM
  2237. echo ":0" >> $PM
  2238. echo " * ^From: $EMAILADDRESS" >> $PM
  2239. echo "$LISTDIR/new" >> $PM
  2240. chown $MYUSERNAME:$MYUSERNAME $PM
  2241. if [ ! -f "$MUTTRC" ]; then
  2242. cp /etc/Muttrc $MUTTRC
  2243. chown $MYUSERNAME:$MYUSERNAME $MUTTRC
  2244. fi
  2245. PROCMAILLOG=/home/$MYUSERNAME/log
  2246. if [ ! -d $PROCMAILLOG ]; then
  2247. mkdir $PROCMAILLOG
  2248. chown -R $MYUSERNAME:$MYUSERNAME $PROCMAILLOG
  2249. fi
  2250. #+END_SRC
  2251. Save and exit, then make the script executable.
  2252. #+BEGIN_SRC: bash
  2253. chmod +x /usr/bin/emailrule
  2254. #+END_SRC
  2255. Then to add a particular email address to a folder run the command:
  2256. #+BEGIN_SRC: bash
  2257. emailrule [myusername] [emailaddress] [foldername]
  2258. #+END_SRC
  2259. If you want any mail from the given email address to be deleted then set the /foldername/ to /Trash/.
  2260. To ensure that the folder appears within Mutt.
  2261. #+BEGIN_SRC: bash
  2262. editor /home/myusername/.muttrc
  2263. #+END_SRC
  2264. Search for the *mailboxes* variable and add entries for the mailing lists you just created. For example:
  2265. #+BEGIN_SRC: bash
  2266. mailboxes = =Sent =foldername
  2267. #+END_SRC
  2268. Then save and exit.
  2269. ** Install a Blog
  2270. #+BEGIN_VERSE
  2271. /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./
  2272. -- Nick Cohen
  2273. #+END_VERSE
  2274. 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.
  2275. 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.
  2276. Download flatpress.
  2277. #+BEGIN_SRC: bash
  2278. cd /tmp
  2279. wget http://freedombone.uk.to/flatpress.tar.gz
  2280. #+END_SRC
  2281. Verify the download:
  2282. #+BEGIN_SRC: bash
  2283. sha256sum flatpress.tar.gz
  2284. 6312a49aab5aabd6371518dcaf081f489dff04d001bc34b4fe3f2a81170bbd4e flatpress.tar.gz
  2285. #+END_SRC
  2286. Extract and install it.
  2287. #+BEGIN_SRC: bash
  2288. tar -xzvf flatpress.tar.gz
  2289. cd flatpress-*
  2290. cp -r * /var/www/$HOSTNAME/htdocs
  2291. cd ..
  2292. rm -rf flatpress-*
  2293. rm -f flatpress.tar.gz
  2294. #+END_SRC
  2295. 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
  2296. ** Install an IRC server
  2297. #+BEGIN_VERSE
  2298. /Give me the liberty to know, to utter, and to argue freely according to conscience, above all liberties./
  2299. -- John Milton
  2300. #+END_VERSE
  2301. *** Base install
  2302. 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.
  2303. First install some dependencies.
  2304. #+BEGIN_SRC: bash
  2305. apt-get update
  2306. apt-get install build-essential openssl libssl-dev debhelper dpatch docbook-to-man flex bison libpcre3-dev
  2307. #+END_SRC
  2308. Then get the source code for ircd-hybrid.
  2309. #+BEGIN_SRC: bash
  2310. cd /tmp
  2311. mkdir hybrid
  2312. cd hybrid
  2313. apt-get source ircd-hybrid
  2314. #+END_SRC
  2315. Modify the source code to include SSL security.
  2316. #+BEGIN_SRC: bash
  2317. editor ircd-hybrid-*/debian/rules
  2318. #+END_SRC
  2319. Beneath MAXCLIENTS add the line:
  2320. #+BEGIN_SRC: bash
  2321. USE_OPENSSL = 1
  2322. #+END_SRC
  2323. Then save and exit. Now we can build the debian package for ircd-hybrid and install it.
  2324. #+BEGIN_SRC: bash
  2325. cd ircd-hybrid-*
  2326. dpkg-buildpackage -rfakeroot -uc -b
  2327. cd ..
  2328. dpkg -i ircd-hybrid_*.deb
  2329. #+END_SRC
  2330. 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.
  2331. #+BEGIN_SRC: bash
  2332. editor /etc/ircd-hybrid/ircd.conf
  2333. #+END_SRC
  2334. Set *name* to the name of your server, and set a description.
  2335. Set a *network_name* and *network_desc*. The network name should not contain any spaces.
  2336. Set max_clients to 20, or however many you expect that you'll typically need.
  2337. Within the admin section set your *name* and *email*.
  2338. Within the *listen* section set host to your fixed IP address (in the earlier
  2339. sections it was 192.168.1.60).
  2340. Within the *auth* section set user = "*@192.168.1.60" - or whatever the fixed IP address of the BBB is on your network.
  2341. 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.
  2342. Save and exit, then restart the IRC server. Open port 6670 on your internet router and forward it to the BBB.
  2343. Ensure that the configuration is only readable by the root user.
  2344. #+BEGIN_SRC: bash
  2345. chmod 600 /etc/ircd-hybrid/ircd.conf
  2346. #+END_SRC
  2347. *** Channel management
  2348. To to install channel management tools.
  2349. #+BEGIN_SRC: bash
  2350. cd /tmp
  2351. wget http://freedombone.uk.to/hybserv_1.9.4-1_armhf.deb
  2352. #+END_SRC
  2353. Verify it.
  2354. #+BEGIN_SRC: bash
  2355. sha256sum hybserv_1.9.4-1_armhf.deb
  2356. 41bf4eb6e24c87610a80bc14db1103a57484835510eea7e4ba9709c523318615 hybserv_1.9.4-1_armhf.deb
  2357. #+END_SRC
  2358. Install it.
  2359. #+BEGIN_SRC: bash
  2360. dpkg -i hybserv_1.9.4-1_armhf.deb
  2361. #+END_SRC
  2362. Make a md5 version of the password for the IRC server operator.
  2363. #+BEGIN_SRC: bash
  2364. /usr/bin/mkpasswd <myoperatorpassword>
  2365. #+END_SRC
  2366. Edit the ircd-hybrid configuration.
  2367. #+BEGIN_SRC: bash
  2368. editor /etc/ircd-hybrid/ircd.conf
  2369. #+END_SRC
  2370. Enter the md5 password which you previously created within the /operator/ section. Also change /user/ to:
  2371. #+BEGIN_SRC: bash
  2372. user = "*@*";
  2373. #+END_SRC
  2374. Then save and exit.
  2375. #+BEGIN_SRC: bash
  2376. editor /etc/hybserv/hybserv.conf
  2377. #+END_SRC
  2378. 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/.
  2379. #+BEGIN_SRC: bash
  2380. A:mynickname <myemailaddress>
  2381. N:irc.mydomainname.com:Hybrid services
  2382. O:*@*:#MD5 PASSWORD HERE#:root:segj (comment out other Q: lines)
  2383. S:mysendacceptpassword:192.168.1.60:6670 (remove the other two services)
  2384. #+END_SRC
  2385. Also remove the line *#NOT-EDITED#*, then save and exit.
  2386. Now we need to restart the ircd and hybrid server to make things work:
  2387. #+BEGIN_SRC: bash
  2388. service ircd-hybrid restart
  2389. service hybserv start
  2390. #+END_SRC
  2391. *** Usage with Irssi
  2392. On another computer (not the BBB).
  2393. #+BEGIN_SRC: bash
  2394. sudo apt-get install irssi irssi-plugin-otr irssi-plugin-xmpp
  2395. irssi
  2396. #+END_SRC
  2397. 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".
  2398. #+BEGIN_SRC: bash
  2399. /network add -nick mynick mynetwork
  2400. /channel add -auto #mychannel mynetwork channelpassword
  2401. /server add -auto -network mynetwork -ssl mydonainname.com 6670 mysendacceptpassword
  2402. /connect mydomainname.com
  2403. /join #mychannel
  2404. /msg -servername chanserv REGISTER #mychannel channelpassword
  2405. /msg -servername chanserv set #mychannel mlock +k channelpassword
  2406. /set paste_join_multiline OFF
  2407. #+END_SRC
  2408. If you edit the irssi config file:
  2409. #+BEGIN_SRC: bash
  2410. editor ~/.irssi/config
  2411. #+END_SRC
  2412. It should look something like this:
  2413. #+BEGIN_SRC: bash
  2414. {
  2415. address = "mydomainname.com";
  2416. chatnet = "mynetwork";
  2417. port = "6670";
  2418. password = "mysendacceptpassword";
  2419. use_ssl = "yes";
  2420. ssl_verify = "no";
  2421. autoconnect = "yes";
  2422. },
  2423. #+END_SRC
  2424. If you're not using a self-signed certificate (self-signed is the default) then you can set *ssl_verify* to "yes".
  2425. By default irssi will use UTC time. An example of setting to some other time zone is as follows:
  2426. #+BEGIN_SRC: bash
  2427. echo "load perl" >> ~/.irssi/startup
  2428. echo "script exec $ENV{'TZ'}='Europe/London';" >> ~/.irssi/startup
  2429. #+END_SRC
  2430. Also enable /Off The Record/ (OTR) messaging.
  2431. #+BEGIN_SRC: bash
  2432. echo "load otr" >> ~/.irssi/startup
  2433. #+END_SRC
  2434. By default Irssi does not look especially attractive. To improve it's looks:
  2435. #+BEGIN_SRC: bash
  2436. cd ~/.irssi
  2437. wget http://freedombone.uk.to/irssi/xchat.theme
  2438. mkdir ~/.irssi/scripts
  2439. mkdir ~/.irssi/scripts/autorun
  2440. cd ~/.irssi/scripts/autorun
  2441. wget http://freedombone.uk.to/irssi/xchatnickcolor.pl
  2442. wget http://freedombone.uk.to/irssi/adv_windowlist.pl
  2443. #+END_SRC
  2444. Verify the files:
  2445. #+BEGIN_SRC: bash
  2446. sha256sum ~/.irssi/xchat.theme
  2447. 7a84130ad55aabd0b043a03b013628438e6c7f82a58e15267633bc7eb443e60b
  2448. sha256sum ~/.irssi/scripts/autorun/xchatnickcolor.pl
  2449. 8293e867a22d42ce5a28cd755237509b6f3587fd2b21d7d20af4a832081610ca
  2450. sha256sum ~/.irssi/scripts/autorun/adv_windowlist.pl
  2451. e4dd8f6d384bf4f2d0ab5ccf06df06e4a69d2647b08d37c8fc6cfd9326688395
  2452. #+END_SRC
  2453. Then run Irssi and enter the commands:
  2454. #+BEGIN_SRC: bash
  2455. /set theme xchat
  2456. /statusbar window remove act
  2457. /set awl
  2458. /set awl_block -14
  2459. /set awl_display_key $Q%K|$N%n $H$C$S
  2460. /set awl_display_key_active $Q%K|$N%n $H%U$C%n$S
  2461. /set awl_display_nokey [$N]$H$C$S
  2462. /run autorun/adv_windowlist.pl
  2463. /set awl_viewer off
  2464. /save
  2465. #+END_SRC
  2466. *** Using irssi with Off The Record messaging (OTR)
  2467. Once you're running irssi then you can enable OTR with:
  2468. #+BEGIN_SRC: bash
  2469. /statusbar window add otr
  2470. /otr genkey mynick@network (for example mynick@irc.freenode.net)
  2471. #+END_SRC
  2472. Then to see your OTR fingerprint:
  2473. #+BEGIN_SRC: bash
  2474. /otr info
  2475. #+END_SRC
  2476. And to trust or distrust someone else's fingerprint.
  2477. #+BEGIN_SRC: bash
  2478. /otr trust [fingerprint]
  2479. /otr distrust [fingerprint]
  2480. #+END_SRC
  2481. *** Usage with XChat
  2482. Within the network list click, *Add* and enter your domain name then click *Edit*.
  2483. Select the entry within the servers box, then enter *mydomainname.com/6670* and press *Enter*.
  2484. Uncheck *use global user information*.
  2485. Enter first and second nicknames and check *auto connect to this network on startup*.
  2486. Check *use SSL* and *accept invalid SSL certificate*.
  2487. Enter some favourite channels and within *server password* enter /mysendacceptpassword/ which you defined earlier when setting up the server.
  2488. Click *close* and then *connect*.
  2489. *** Install Irssi as a daemon
  2490. 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.
  2491. First install some prerequisites.
  2492. #+BEGIN_SRC: bash
  2493. apt-get install irssi irssi-plugin-otr irssi-plugin-xmpp screen
  2494. #+END_SRC
  2495. Create an initialisation script.
  2496. #+BEGIN_SRC: bash
  2497. editor /etc/init.d/irssid
  2498. #+END_SRC
  2499. Add the following:
  2500. #+BEGIN_SRC: bash
  2501. #!/bin/bash
  2502. ### BEGIN INIT INFO
  2503. # Provides: irssid
  2504. # Required-Start: $network
  2505. # Required-Stop: $network
  2506. # Default-Start: 2 3 4 5
  2507. # Default-Stop: 0 1 6
  2508. # Short-Description: Start irssi daemon within screen session at boot time
  2509. # Description: This init script will start an irssi session under screen using the settings provided in /etc/irssid.conf
  2510. ### END INIT INFO
  2511. # Include the LSB library functions
  2512. . /lib/lsb/init-functions
  2513. # Setup static variables
  2514. configFile='/etc/irssid.conf'
  2515. daemonExec='/usr/bin/screen'
  2516. daemonArgs='-D -m'
  2517. daemonName="$(basename "$daemonExec")"
  2518. pidFile='/var/run/irssid.pid'
  2519. #
  2520. # Checks if the environment is capable of running the script (such as
  2521. # availability of programs etc).
  2522. #
  2523. # Return: 0 if the environmnt is properly setup for execution of init script, 1
  2524. # if not all conditions have been met.
  2525. #
  2526. function checkEnvironment() {
  2527. # Verify that the necessary binaries are available for execution.
  2528. local binaries=(irssi screen)
  2529. for bin in "${binaries[@]}"; do
  2530. if ! which "$bin" > /dev/null; then
  2531. log_failure_msg "Binary '$bin' is not available. Please install \
  2532. package containing it."
  2533. exit 5
  2534. fi
  2535. done
  2536. }
  2537. #
  2538. # Checks if the configuration files are available and properly setup.
  2539. #
  2540. # Return: 0 if irssid if properly configured, 1 otherwise.
  2541. #
  2542. function checkConfig() {
  2543. # Make sure the configuration file has been created
  2544. if ! [[ -f $configFile ]]; then
  2545. log_failure_msg "Please populate the configuration file '$configFile' \
  2546. before running."
  2547. exit 6
  2548. fi
  2549. # Make sure the required options have been set
  2550. local reqOptions=(user group session)
  2551. for option in "${reqOptions[@]}"; do
  2552. if ! grep -q -e "^[[:blank:]]*$option=" "$configFile"; then
  2553. log_failure_msg "Mandatory option '$option' was not specified in \
  2554. '$configFile'"
  2555. exit 6
  2556. fi
  2557. done
  2558. }
  2559. #
  2560. # Loads the configuration file and performs any additional configuration steps.
  2561. #
  2562. function configure() {
  2563. . "$configFile"
  2564. daemonArgs="$daemonArgs -S $session irssi"
  2565. [[ -n $args ]] && daemonArgs="$daemonArgs $args"
  2566. daemonCommand="$daemonExec $daemonArgs"
  2567. }
  2568. #
  2569. # Starts the daemon.
  2570. #
  2571. # Return: LSB-compliant code.
  2572. #
  2573. function start() {
  2574. start-stop-daemon --start -v -b -x /bin/su -p /tmp/irssi.screen.session -m --chdir /home/$user -- - $user -c "screen -D -m -S irssi -- irssi" 1>>/log.irssi
  2575. }
  2576. #
  2577. # Stops the daemon.
  2578. #
  2579. # Return: LSB-compliant code.
  2580. #
  2581. function stop() {
  2582. start-stop-daemon --stop -x /bin/su -p /tmp/irssi.screen.session -q
  2583. }
  2584. checkEnvironment
  2585. checkConfig
  2586. configure
  2587. case "$1" in
  2588. start)
  2589. log_daemon_msg "Starting daemon" "irssid"
  2590. start && log_end_msg 0 || log_end_msg $?
  2591. ;;
  2592. stop)
  2593. log_daemon_msg "Stopping daemon" "irssid"
  2594. stop && log_end_msg 0 || log_end_msg $?
  2595. ;;
  2596. restart)
  2597. log_daemon_msg "Restarting daemon" "irssid"
  2598. stop
  2599. start && log_end_msg 0 || log_end_msg $?
  2600. ;;
  2601. force-reload)
  2602. log_daemon_msg "Restarting daemon" "irssid"
  2603. stop
  2604. start && log_end_msg 0 || log_end_msg $?
  2605. ;;
  2606. status)
  2607. status_of_proc -p "$pidFile" "$daemonExec" screen && exit 0 || exit $?
  2608. ;;
  2609. *)
  2610. echo "irssid (start|stop|restart|force-reload|status|help)"
  2611. ;;
  2612. esac
  2613. #+END_SRC
  2614. Save and exit.
  2615. #+BEGIN_SRC: bash
  2616. chmod +x /etc/init.d/irssid
  2617. #+END_SRC
  2618. Create a configuration file, replacing /myusername/ with your username.
  2619. #+BEGIN_SRC: bash
  2620. editor /etc/irssid.conf
  2621. #+END_SRC
  2622. #+BEGIN_SRC: bash
  2623. #
  2624. # Configuration file for irssid init script
  2625. #
  2626. # Mandatory options:
  2627. #
  2628. # user - Specify user for running irssi.
  2629. # group - Specify group for running irssi.
  2630. # session - Specify screen session name to be used for irssi.
  2631. #
  2632. # Non-mandatory options:
  2633. #
  2634. # args - Pass additional arguments to irssi.
  2635. #
  2636. user='myusername'
  2637. group='irssi'
  2638. session='irssi'
  2639. args='--config /home/myusername/.irssi/config'
  2640. #+END_SRC
  2641. Save and exit. Then add your user to the irssi group and start the daemon.
  2642. #+BEGIN_SRC: bash
  2643. groupadd irssi
  2644. usermod -aG irssi myusername
  2645. update-rc.d irssid defaults
  2646. chown -R myusername:irssi /home/myusername/.irssi
  2647. service irssid start
  2648. #+END_SRC
  2649. Create a script to make running IRC on the server easier.
  2650. #+BEGIN_SRC: bash
  2651. editor /usr/bin/irc
  2652. #+END_SRC
  2653. Add the following:
  2654. #+BEGIN_SRC: bash
  2655. #!/bin/bash
  2656. screen -r irssi
  2657. #+END_SRC
  2658. Save and exit.
  2659. #+BEGIN_SRC: bash
  2660. chmod +x /usr/bin/irc
  2661. chown myusername:myusername /usr/bin/irc
  2662. #+END_SRC
  2663. Then to subsequently access irssi log into the BBB using ssh and type:
  2664. #+BEGIN_SRC: bash
  2665. irc
  2666. #+END_SRC
  2667. ** Install a Jabber/XMPP server
  2668. #+BEGIN_VERSE
  2669. /Well heck, it isn’t that hard to write an instant messaging system./
  2670. --Jeremie Miller
  2671. #+END_VERSE
  2672. *** The Server
  2673. Generate a SSL certificate.
  2674. #+BEGIN_SRC: bash
  2675. openssl ecparam -out /etc/ssl/private/xmpp.pem -name prime256v1
  2676. openssl genpkey -paramfile /etc/ssl/private/xmpp.pem -out /etc/ssl/private/xmpp.key
  2677. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  2678. #+END_SRC
  2679. 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:
  2680. #+BEGIN_SRC: bash
  2681. openssl genrsa -out /etc/ssl/private/xmpp.key 4096
  2682. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  2683. #+END_SRC
  2684. Change permissions.
  2685. #+BEGIN_SRC: bash
  2686. chmod 600 /etc/ssl/private/xmpp.key
  2687. chmod 600 /etc/ssl/certs/xmpp.crt
  2688. chown prosody:prosody /etc/ssl/private/xmpp.key
  2689. chown prosody:prosody /etc/ssl/certs/xmpp.crt
  2690. #+END_SRC
  2691. Install Prosody.
  2692. #+BEGIN_SRC: bash
  2693. apt-get install prosody
  2694. cp -a /etc/prosody/conf.avail/example.com.cfg.lua /etc/prosody/conf.avail/xmpp.cfg.lua
  2695. editor /etc/prosody/conf.avail/xmpp.cfg.lua
  2696. #+END_SRC
  2697. Change the *VirtualHost* name to your domain name and remove the line below it.
  2698. Set the ssl section to:
  2699. #+BEGIN_SRC: bash
  2700. ssl = {
  2701. key = "/etc/ssl/private/xmpp.key";
  2702. certificate = "/etc/ssl/certs/xmpp.crt";
  2703. }
  2704. #+END_SRC
  2705. And also append the following:
  2706. #+BEGIN_SRC: bash
  2707. modules_enabled = {
  2708. "bosh"; -- Enable mod_bosh
  2709. "tls"; -- Enable mod_tls
  2710. }
  2711. c2s_require_encryption = true
  2712. s2s_require_encryption = true
  2713. #+END_SRC
  2714. Save and exit. Create a symbolic link.
  2715. #+BEGIN_SRC: bash
  2716. ln -sf /etc/prosody/conf.avail/xmpp.cfg.lua /etc/prosody/conf.d/xmpp.cfg.lua
  2717. #+END_SRC
  2718. 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).
  2719. #+BEGIN_SRC: bash
  2720. prosodyctl adduser myusername@mydomainname.com
  2721. #+END_SRC
  2722. Restart the server
  2723. #+BEGIN_SRC: bash
  2724. service prosody restart
  2725. #+END_SRC
  2726. On your internet router/firewall open ports 5222, 5223, 5269, 5280 and 5281 and forward them to the BBB.
  2727. 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.
  2728. *** Managing users
  2729. To add a user:
  2730. #+BEGIN_SRC: bash
  2731. prosodyctl adduser myusername@mydomainname.com
  2732. #+END_SRC
  2733. To change a user password:
  2734. #+BEGIN_SRC: bash
  2735. prosodyctl passwd myusername@mydomainname.com
  2736. #+END_SRC
  2737. To remove a user:
  2738. #+BEGIN_SRC: bash
  2739. prosodyctl deluser myusername@mydomainname.com
  2740. #+END_SRC
  2741. Report the status of the XMPP server:
  2742. #+BEGIN_SRC: bash
  2743. prosodyctl status
  2744. #+END_SRC
  2745. *** Using with Jitsi
  2746. 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.
  2747. Jitsi can be downloaded from https://jitsi.org/
  2748. On your desktop/laptop open Jitsi and select *Options* from the *Tools* menu.
  2749. 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).
  2750. 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.
  2751. 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.
  2752. You can also [[https://www.youtube.com/watch?v=vgx7VSrDGjk][see this video]] as an example of using OTR.
  2753. *** Using with Ubuntu
  2754. 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.
  2755. Open *System Settings* and select *Online Accounts*, *Add account* and then *Jabber*.
  2756. Enter your username (myusername@mydomainname.com) and password.
  2757. 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*.
  2758. *** Using with Android
  2759. There are a few XMPP clients available on Android. Ideally choose ones which support off-the-record messaging. Here are some examples.
  2760. **** Xabber
  2761. Install [[https://f-droid.org/][F-Droid]]
  2762. Search for and install Xabber.
  2763. Add an account and enter your Jabber/XMPP ID and password.
  2764. From the menu select *Settings* then *Security* then *OTR mode*. Set the mode to *Required*.
  2765. Make sure that *Check server certificate* is not checked.
  2766. 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.
  2767. **** Gibberbot
  2768. Install [[https://f-droid.org/][F-Droid]]
  2769. Search for and install Gibberbot, otherwise known as ChatSecure.
  2770. From the menu open *Accounts*
  2771. Select *Add account*
  2772. Change the server port from 0 to 5222
  2773. Done
  2774. Accept unknown certificate? Select *Always*
  2775. Go back to the initial screen and then using the menu you can add contacts and begin chatting.
  2776. ** Social Networking
  2777. #+BEGIN_VERSE
  2778. /Facebook is not your friend, it is a surveillance engine./
  2779. -- Richard Stallman, Free Software Foundation
  2780. #+END_VERSE
  2781. *** Friendica
  2782. **** Installation
  2783. 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.
  2784. 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:
  2785. #+BEGIN_SRC: bash
  2786. editor /etc/apache2/sites-available/myfriendicadomainname.com
  2787. #+END_SRC
  2788. Replace the section which begins with *<VirtualHost *:80>* with the following, replacing /myusername@mydomainname.com/ with your email address and /myfriendicadomainname.com/ with your Friendica domain name:
  2789. #+BEGIN_SRC: bash
  2790. <VirtualHost *:80>
  2791. ServerAdmin myusername@mydomainname.com
  2792. ServerName myfriendicadomainname.com
  2793. RewriteEngine On
  2794. RewriteCond %{HTTPS} off
  2795. RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
  2796. </VirtualHost>
  2797. #+END_SRC
  2798. Save and exit, then restart the apache server.
  2799. #+BEGIN_SRC: bash
  2800. service apache2 restart
  2801. #+END_SRC
  2802. Now install some dependencies.
  2803. #+BEGIN_SRC: bash
  2804. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  2805. #+END_SRC
  2806. Enter an admin password for MySQL.
  2807. Reduce the memory use of mysql by using the "small" configuration.
  2808. #+BEGIN_SRC: bash
  2809. cp /usr/share/doc/mysql-server-5.5/examples/my-small.cnf /etc/mysql/my.cnf
  2810. #+END_SRC
  2811. Create a mysql database.
  2812. #+BEGIN_SRC: bash
  2813. mysql -u root -p
  2814. create database friendica;
  2815. CREATE USER 'friendicaadmin'@'localhost' IDENTIFIED BY 'password';
  2816. GRANT ALL PRIVILEGES ON friendica.* TO 'friendicaadmin'@'localhost';
  2817. quit
  2818. #+END_SRC
  2819. You may need to fix Git SSL problems.
  2820. #+BEGIN_SRC: bash
  2821. git config --global http.sslVerify true
  2822. apt-get install ca-certificates
  2823. cd ~/
  2824. editor .gitconfig
  2825. #+END_SRC
  2826. The .gitconfig file should look something like this:
  2827. #+BEGIN_SRC: bash
  2828. [http]
  2829. sslVerify = true
  2830. sslCAinfo = /etc/ssl/certs/ca-certificates.crt
  2831. [user]
  2832. email = myusername@mydomainname.com
  2833. name = yourname
  2834. #+END_SRC
  2835. Get the source code.
  2836. #+BEGIN_SRC: bash
  2837. export HOSTNAME=myfriendicadomainname.com
  2838. cd /var/www/$HOSTNAME
  2839. mv htdocs htdocs_old
  2840. git clone https://github.com/friendica/friendica.git htdocs
  2841. chmod -R 755 htdocs
  2842. chown -R www-data:www-data htdocs
  2843. chown -R www-data:www-data htdocs/view/smarty3
  2844. git clone https://github.com/friendica/friendica-addons.git htdocs/addon
  2845. #+END_SRC
  2846. 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.
  2847. Install the poller.
  2848. #+BEGIN_SRC: bash
  2849. editor /etc/crontab
  2850. #+END_SRC
  2851. and append the following, changing /myfriendicadomainname.com/ to whatever your Friendica domain is.
  2852. #+BEGIN_SRC: bash
  2853. */10 * * * * root cd /var/www/myfriendicadomainname.com/htdocs; /usr/bin/timeout 120 /usr/bin/php include/poller.php
  2854. #+END_SRC
  2855. Save and exit, then restart cron.
  2856. #+BEGIN_SRC: bash
  2857. service cron restart
  2858. #+END_SRC
  2859. You can improve the speed of Friendica database searches by adding the following indexes:
  2860. #+BEGIN_SRC: bash
  2861. mysql -u root -p
  2862. use friendica;
  2863. CREATE INDEX `uri_received` ON item(`uri`, `received`);
  2864. CREATE INDEX `received_uri` ON item(`received`, `uri`);
  2865. CREATE INDEX `contact-id_created` ON item(`contact-id`, created);
  2866. CREATE INDEX `uid_network_received` ON item(`uid`, `network`, `received`);
  2867. CREATE INDEX `uid_parent` ON item(`uid`, `parent`);
  2868. CREATE INDEX `uid_received` ON item(`uid`, `received`);
  2869. CREATE INDEX `uid_network_commented` ON item(`uid`, `network`, `commented`);
  2870. CREATE INDEX `uid_title` ON item(uid, `title`);
  2871. CREATE INDEX `created_contact-id` ON item(`created`, `contact-id`);
  2872. quit
  2873. #+END_SRC
  2874. Make sure that Friendica doesn't use too much memory.
  2875. #+BEGIN_SRC: bash
  2876. editor /var/www/$HOSTNAME/htdocs/.htaccess
  2877. #+END_SRC
  2878. Append the following:
  2879. #+BEGIN_SRC: bash
  2880. php_value memory_limit 32M
  2881. #+END_SRC
  2882. The save ane exit.
  2883. **** Backups
  2884. 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.
  2885. #+BEGIN_SRC: bash
  2886. editor /etc/cron.daily/backup
  2887. #+END_SRC
  2888. Enter the following
  2889. #+BEGIN_SRC: bash
  2890. #!/bin/sh
  2891. # stop the web server to avoid any changes to the databases during backup
  2892. service apache2 stop
  2893. MYSQL_PASSWORD=<mysql root password>
  2894. umask 0077
  2895. # Backup the database
  2896. mysqldump --password=$MYSQL_PASSWORD friendica > /var/backups/friendica_daily.sql
  2897. # Make the backup readable only by root
  2898. chmod 600 /var/backups/friendica_daily.sql
  2899. # Backup the database
  2900. #mysqldump --password=$MYSQL_PASSWORD redmatrix > /var/backups/redmatrix_daily.sql
  2901. # Make the backup readable only by root
  2902. #chmod 600 /var/backups/redmatrix_daily.sql
  2903. # restart the web server
  2904. service apache2 start
  2905. #+END_SRC
  2906. Save and exit.
  2907. #+BEGIN_SRC: bash
  2908. chmod 600 /etc/cron.daily/backup
  2909. chmod +x /etc/cron.daily/backup
  2910. editor /etc/cron.weekly/backup
  2911. #+END_SRC
  2912. Enter the following
  2913. #+BEGIN_SRC: bash
  2914. #!/bin/sh
  2915. umask 0077
  2916. # Friendica
  2917. cp -f /var/backups/friendica_weekly.sql /var/backups/friendica_2weekly.sql
  2918. cp -f /var/backups/friendica_daily.sql /var/backups/friendica_weekly.sql
  2919. # Red Matrix
  2920. #cp -f /var/backups/redmatrix_weekly.sql /var/backups/redmatrix_2weekly.sql
  2921. #cp -f /var/backups/redmatrix_daily.sql /var/backups/redmatrix_weekly.sql
  2922. #+END_SRC
  2923. Save and exit.
  2924. #+BEGIN_SRC: bash
  2925. chmod 600 /etc/cron.weekly/friendicabackup
  2926. chmod +x /etc/cron.weekly/friendicabackup
  2927. editor /etc/cron.monthly/backup
  2928. #+END_SRC
  2929. Enter the following
  2930. #+BEGIN_SRC: bash
  2931. #!/bin/sh
  2932. # Friendica
  2933. cp -f /var/backups/friendica_monthly.sql /var/backups/friendica_2monthly.sql
  2934. cp -f /var/backups/friendica_weekly.sql /var/backups/friendica_monthly.sql
  2935. # Red Matrix
  2936. #cp -f /var/backups/redmatrix_monthly.sql /var/backups/redmatrix_2monthly.sql
  2937. #cp -f /var/backups/redmatrix_weekly.sql /var/backups/redmatrix_monthly.sql
  2938. #+END_SRC
  2939. Save and exit.
  2940. **** Recommended configuration
  2941. ***** Admin
  2942. 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.
  2943. 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.
  2944. Under the *themes* section select a few themes, including mobile themes which are suitable for phones or tablets.
  2945. 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.
  2946. 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]].
  2947. ***** Settings
  2948. Each user has their own customisable settings, typically available either via an icon or by an entry on a drop down menu.
  2949. Under *additional features* enable "/richtext editor/", "/post preview/", "/group filter/", "/network filter/", "/edit sent posts/" and "/dislike posts/".
  2950. Under *display settings* select your desktop and mobile themes.
  2951. 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.
  2952. **** To access from an Android device
  2953. ***** App
  2954. 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.
  2955. 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.
  2956. More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
  2957. ***** Mobile Theme
  2958. 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.
  2959. *** Movim
  2960. #+BEGIN_VERSE
  2961. /The way we communicate with others and with ourselves ultimately determines the quality of our lives/
  2962. -- Anthony Robbins
  2963. #+END_VERSE
  2964. Movim is another social networking system based around the XMPP protocol.
  2965. You will need to have previously [[Install a Jabber/XMPP server][installed the Jabber/XMPP server]].
  2966. 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:
  2967. #+BEGIN_SRC: bash
  2968. editor /etc/apache2/sites-available/mydomainname.com
  2969. #+END_SRC
  2970. Within the section which begins with *<VirtualHost *:80>* add the following:
  2971. #+BEGIN_SRC: bash
  2972. <Directory /var/www/mydomainname.com/htdocs/movim>
  2973. deny from all
  2974. </Directory>
  2975. #+END_SRC
  2976. Within the section which begins with *<VirtualHost *:443>* add the following:
  2977. #+BEGIN_SRC: bash
  2978. <Directory /var/www/mydomainname.com/htdocs/movim>
  2979. Options Indexes FollowSymLinks MultiViews
  2980. AllowOverride All
  2981. Order allow,deny
  2982. allow from all
  2983. </Directory>
  2984. #+END_SRC
  2985. Save and exit, then restart the apache server.
  2986. #+BEGIN_SRC: bash
  2987. service apache2 restart
  2988. #+END_SRC
  2989. Download the source.
  2990. #+BEGIN_SRC: bash
  2991. cd /tmp
  2992. wget http://freedombone.uk.to/movim.tar.gz
  2993. #+END_SRC
  2994. Verify it.
  2995. #+BEGIN_SRC: bash
  2996. sha256sum movim.tar.gz
  2997. 2740ddbedf6cefcc2934759374376643b6cdea4fb7f944ec25098a6868cb499e movim.tar.gz
  2998. #+END_SRC
  2999. Install it.
  3000. #+BEGIN_SRC: bash
  3001. tar -xzvf movim.tar.gz
  3002. export HOSTNAME=mydomainname.com
  3003. cp -r movim-* /var/www/$HOSTNAME/htdocs/movim
  3004. chmod 755 /var/www/$HOSTNAME/htdocs/movim
  3005. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/movim
  3006. #+END_SRC
  3007. Install some MySql prerequisites.
  3008. #+BEGIN_SRC: bash
  3009. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  3010. #+END_SRC
  3011. If necessary, enter an admin password for MySQL.
  3012. Reduce the memory use of mysql by using the "small" configuration.
  3013. #+BEGIN_SRC: bash
  3014. cp /usr/share/doc/mysql-server-5.5/examples/my-small.cnf /etc/mysql/my.cnf
  3015. #+END_SRC
  3016. Create a mysql database.
  3017. #+BEGIN_SRC: bash
  3018. mysql -u root -p
  3019. create database movim;
  3020. CREATE USER 'movimadmin'@'localhost' IDENTIFIED BY 'movimadminpassword';
  3021. GRANT ALL PRIVILEGES ON movim.* TO 'movimadmin'@'localhost';
  3022. quit
  3023. #+END_SRC
  3024. With a web browser navigate to:
  3025. https://mydomainname.com/movim/admin
  3026. Enter /admin/ as the username and /password/ as the password.
  3027. 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).
  3028. Change the /Environment/ from /Development/ to /Production/.
  3029. 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?)
  3030. Click /Submit/ followed by /Resend/.
  3031. Click on /Database Settings/ and alter the MySql movim database username to /movimadmin/ and password to the password you specified in the previous step.
  3032. 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".
  3033. 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).
  3034. *** Red Matrix
  3035. **** Introduction
  3036. 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.
  3037. **** Prerequisites
  3038. 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.
  3039. 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.
  3040. **** Installation
  3041. 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.
  3042. 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:
  3043. #+BEGIN_SRC: bash
  3044. editor /etc/apache2/sites-available/mydomainname.com
  3045. #+END_SRC
  3046. Replace the section which begins with *<VirtualHost *:80>* with the following:
  3047. #+BEGIN_SRC: bash
  3048. <VirtualHost *:80>
  3049. ServerAdmin myusername@mydomainname.com
  3050. ServerName myredmatrixdomainname.com
  3051. RewriteEngine On
  3052. RewriteCond %{HTTPS} off
  3053. RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
  3054. </VirtualHost>
  3055. #+END_SRC
  3056. Save and exit, then restart the apache server.
  3057. #+BEGIN_SRC: bash
  3058. service apache2 restart
  3059. #+END_SRC
  3060. Now install some dependencies.
  3061. #+BEGIN_SRC: bash
  3062. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  3063. #+END_SRC
  3064. Enter an admin password for MySQL.
  3065. Reduce the memory use of mysql by using the "small" configuration.
  3066. #+BEGIN_SRC: bash
  3067. cp /usr/share/doc/mysql-server-5.5/examples/my-small.cnf /etc/mysql/my.cnf
  3068. #+END_SRC
  3069. Create a mysql database.
  3070. #+BEGIN_SRC: bash
  3071. mysql -u root -p
  3072. create database redmatrix;
  3073. CREATE USER 'redmatrixadmin'@'localhost' IDENTIFIED BY 'password';
  3074. GRANT ALL PRIVILEGES ON redmatrix.* TO 'redmatrixadmin'@'localhost';
  3075. quit
  3076. #+END_SRC
  3077. You may need to fix Git SSL problems.
  3078. #+BEGIN_SRC: bash
  3079. git config --global http.sslVerify true
  3080. apt-get install ca-certificates
  3081. cd ~/
  3082. editor .gitconfig
  3083. #+END_SRC
  3084. The .gitconfig file should look something like this:
  3085. #+BEGIN_SRC: bash
  3086. [http]
  3087. sslVerify = true
  3088. sslCAinfo = /etc/ssl/certs/ca-certificates.crt
  3089. [user]
  3090. email = myusername@mydomainname.com
  3091. name = yourname
  3092. #+END_SRC
  3093. Get the source code.
  3094. #+BEGIN_SRC: bash
  3095. export HOSTNAME=mydomainname.com
  3096. cd /var/www/$HOSTNAME
  3097. rm -rf htdocs
  3098. git clone https://github.com/friendica/red.git htdocs
  3099. chmod -R 755 htdocs
  3100. chown -R www-data:www-data htdocs
  3101. mkdir htdocs/view/tpl/smarty3
  3102. chmod 777 htdocs/view/tpl
  3103. chmod 777 htdocs/view/tpl/smarty3
  3104. git clone https://github.com/friendica/red-addons.git htdocs/addon
  3105. #+END_SRC
  3106. 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.
  3107. Install the poller.
  3108. #+BEGIN_SRC
  3109. editor /etc/crontab
  3110. #+END_SRC
  3111. and append the following, changing mydomainname.com to whatever your domain is.
  3112. #+BEGIN_SRC
  3113. 12,22,32,42,52 * * * * root cd /var/www/apespace.org/htdocs; /usr/bin/timeout 240 /usr/bin/php include/poller.php
  3114. #+END_SRC
  3115. Save and exit, then restart cron.
  3116. #+BEGIN_SRC: bash
  3117. service cron restart
  3118. #+END_SRC
  3119. **** Backups
  3120. 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.
  3121. #+BEGIN_SRC: bash
  3122. editor /etc/cron.daily/backup
  3123. #+END_SRC
  3124. If you already have a backup script created for Friendica then just uncomment the lines for Red Matrix. The backup script should look something like the following:
  3125. #+BEGIN_SRC: bash
  3126. #!/bin/sh
  3127. # stop the web server to avoid any changes to the databases during backup
  3128. service apache2 stop
  3129. MYSQL_PASSWORD=elNYCk3hKE5jCjifUUL6ymP7
  3130. umask 0077
  3131. # Backup the database
  3132. mysqldump --password=$MYSQL_PASSWORD friendica > /var/backups/friendica_daily.sql
  3133. # Make the backup readable only by root
  3134. chmod 600 /var/backups/friendica_daily.sql
  3135. # Backup the database
  3136. mysqldump --password=$MYSQL_PASSWORD redmatrix > /var/backups/redmatrix_daily.sql
  3137. # Make the backup readable only by root
  3138. chmod 600 /var/backups/redmatrix_daily.sql
  3139. # restart the web server
  3140. service apache2 start
  3141. #+END_SRC
  3142. Save and exit.
  3143. #+BEGIN_SRC: bash
  3144. chmod 600 /etc/cron.daily/backup
  3145. chmod +x /etc/cron.daily/backup
  3146. editor /etc/cron.weekly/backup
  3147. #+END_SRC
  3148. If you already have a backup script created for Friendica then just uncomment the lines for Red Matrix. The backup script should look something like the following:
  3149. #+BEGIN_SRC: bash
  3150. #!/bin/sh
  3151. umask 0077
  3152. # Friendica
  3153. cp -f /var/backups/friendica_weekly.sql /var/backups/friendica_2weekly.sql
  3154. cp -f /var/backups/friendica_daily.sql /var/backups/friendica_weekly.sql
  3155. # Red Matrix
  3156. cp -f /var/backups/redmatrix_weekly.sql /var/backups/redmatrix_2weekly.sql
  3157. cp -f /var/backups/redmatrix_daily.sql /var/backups/redmatrix_weekly.sql
  3158. #+END_SRC
  3159. Save and exit.
  3160. #+BEGIN_SRC: bash
  3161. chmod 600 /etc/cron.weekly/backup
  3162. chmod +x /etc/cron.weekly/backup
  3163. editor /etc/cron.monthly/backup
  3164. #+END_SRC
  3165. If you already have a backup script created for Friendica then just uncomment the lines for Red Matrix. The backup script should look something like the following:
  3166. #+BEGIN_SRC: bash
  3167. #!/bin/sh
  3168. # Friendica
  3169. cp -f /var/backups/friendica_monthly.sql /var/backups/friendica_2monthly.sql
  3170. cp -f /var/backups/friendica_weekly.sql /var/backups/friendica_monthly.sql
  3171. # Red Matrix
  3172. cp -f /var/backups/redmatrix_monthly.sql /var/backups/redmatrix_2monthly.sql
  3173. cp -f /var/backups/redmatrix_weekly.sql /var/backups/redmatrix_monthly.sql
  3174. #+END_SRC
  3175. Save and exit.
  3176. **** To access from an Android device
  3177. ***** App
  3178. 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.
  3179. 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.
  3180. More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
  3181. *** pump.io
  3182. :PROPERTIES:
  3183. :ORDERED: t
  3184. :END:
  3185. pump.io is the successor to StatusNet (which later became [[GNU Social]]) and is a communications system which can do things other than just microblogging. It takes fewer system resources to run and so is better suited to low power servers such as the BBB, but is more complicated to install. pump.io doesn't work well with self-signed SSL certificates so this may be something which you can only use if you have your own domain and an "authority" issued certificate. Using a self-signed certificate you can only use pump.io as a /data silo/ which won't federate with other servers.
  3186. For a pump.io site you will need a separate domain/subdomain, so see [[Setting up a web site]] for details of how to create an Apache configuration for your site. If you're using freedns then you will need to create a new subdomain.
  3187. #+BEGIN_SRC: bash
  3188. apt-get update && apt-get install redis-server nodejs-legacy imagemagick graphicsmagick git-core screen
  3189. cd /opt
  3190. git clone https://github.com/e14n/pump.io.git
  3191. cd /opt/pump.io
  3192. npm install
  3193. npm install databank-leveldb
  3194. #+END_SRC
  3195. Limit the use of RAM by the Redis database.
  3196. #+BEGIN_SRC: bash
  3197. editor /etc/redis/redis.conf
  3198. #+END_SRC
  3199. Set /maxmemory/ to 16777216 bytes, then save and exit. This should prevent the amount of data stored in memory from making the system unstable.
  3200. Now edit the configuration file.
  3201. #+BEGIN_SRC: bash
  3202. editor /etc/pump.io.json
  3203. #+END_SRC
  3204. Add the following, replacing /mypumpiodomainname.com/ with your domain name.
  3205. #+BEGIN_SRC: bash
  3206. {
  3207. "driver": "redis",
  3208. "params": {"host":"localhost","port":6379},
  3209. "secret": "A long random string",
  3210. "noweb": false,
  3211. "site": "Name of my pump.io site",
  3212. "owner": "My name or organisation",
  3213. "ownerURL": "https://mypumpiodomainname.com/",
  3214. "port": 7270,
  3215. "urlPort": 443,
  3216. "hostname": "mypumpiodomainname.com",
  3217. "address": "localhost",
  3218. "nologger": true,
  3219. "serverUser": "pumpio",
  3220. "rejectUnauthorized": false,
  3221. "key": "/var/local/pump.io/keys/mypumpiodomainname.com.key",
  3222. "cert": "/var/local/pump.io/keys/mypumpiodomainname.com.crt",
  3223. "uploaddir": "/var/local/pump.io/uploads",
  3224. "debugClient": false,
  3225. "firehose": "ofirehose.example",
  3226. "logfile": "/dev/null",
  3227. "disableRegistration": false
  3228. }
  3229. #+END_SRC
  3230. Save and exit.
  3231. #+BEGIN_SRC: bash
  3232. export HOSTNAME=mypumpiodomainname.com
  3233. mkdir /var/local/pump.io
  3234. mkdir /var/local/pump.io/uploads
  3235. mkdir /var/local/pump.io/keys
  3236. cp /etc/ssl/private/$HOSTNAME.key /var/local/pump.io/keys
  3237. cp /etc/ssl/certs/$HOSTNAME.crt /var/local/pump.io/keys
  3238. useradd -s /bin/bash -d /var/local/pump.io pumpio
  3239. chown -R pumpio:pumpio /var/local/pump.io
  3240. chmod 400 /var/local/pump.io/keys/*
  3241. mkdir /tmp/apache2
  3242. cd /tmp/apache2
  3243. apt-get build-dep apache2
  3244. apt-get install autoconf
  3245. apt-get source apache2
  3246. cd apache2-*
  3247. wget http://freedombone.uk.to/apache-2.2-wstunnel.patch
  3248. sha256sum apache-2.2-wstunnel.patch
  3249. cfc4866da2688a8eb76e0300cf16b52539ef4e525053a3851d4b6bba9a77e439
  3250. patch -p1 -i apache-2.2-wstunnel.patch
  3251. autoconf
  3252. ./configure --enable-so --enable-proxy=shared --enable-proxy-wstunnel=shared
  3253. make
  3254. cp modules/proxy/.libs/mod_proxy_wstunnel.so /usr/lib/apache2/modules/
  3255. cd /etc/apache2/mods-enabled
  3256. ln -s /usr/lib/apache2/modules/mod_proxy_wstunnel.so ../mods-available/proxy_wstunnel.load
  3257. #+END_SRC
  3258. Within the section of your Apache site configuration:
  3259. #+BEGIN_SRC: bash
  3260. editor /etc/apache2/sites-available/mypumpiodomainname.com
  3261. #+END_SRC
  3262. The initial section which begins with *<VirtualHost *:80>* should be replaced by the following, replacing /mypumpiodomainname.com/ with your pump.io domain name and /myusername@mydomainname.com/ with your email address.
  3263. #+BEGIN_SRC: bash
  3264. <VirtualHost *:80>
  3265. ServerAdmin myusername@mydomainname.com
  3266. ServerName mypumpiodomainname.com
  3267. RewriteEngine On
  3268. RewriteCond %{HTTPS} off
  3269. RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
  3270. </VirtualHost>
  3271. #+END_SRC
  3272. Add the following in the section which begins with *<VirtualHost *:443>*.
  3273. #+BEGIN_SRC: bash
  3274. ProxyVia On
  3275. ProxyPreserveHost On
  3276. SSLProxyEngine On
  3277. ProxyPass / https://localhost:7270/
  3278. ProxyPassReverse / https://localhost:7270/
  3279. #+END_SRC
  3280. Save and exit.
  3281. #+BEGIN_SRC: bash
  3282. a2enmod cache
  3283. a2enmod disk_cache
  3284. apachectl configtest
  3285. service apache2 restart
  3286. npm install forever -g
  3287. #+END_SRC
  3288. Now create the daemon.
  3289. #+BEGIN_SRC: bash
  3290. editor /etc/init.d/pumpio
  3291. #+END_SRC
  3292. Add the following text:
  3293. #+BEGIN_SRC: bash
  3294. #!/bin/bash
  3295. # /etc/init.d/pumpio
  3296. ### BEGIN INIT INFO
  3297. # Provides: pump.io
  3298. # Required-Start: $remote_fs $syslog
  3299. # Required-Stop: $remote_fs $syslog
  3300. # Default-Start: 2 3 4 5
  3301. # Default-Stop: 0 1 6
  3302. # Short-Description: starts pump.io as a background daemon
  3303. # Description: Starts pump.io on boot
  3304. ### END INIT INFO
  3305. # Author: Bob Mottram <bob@robotics.uk.to>
  3306. #Settings
  3307. SERVICE='pumpio'
  3308. COMMAND="forever /opt/pump.io/bin/pump > /var/local/pump.io/daemon.log"
  3309. USERNAME='pumpio'
  3310. NICELEVEL=19 # from 0-19 the bigger the number, the less the impact on system resources
  3311. HISTORY=1024
  3312. INVOCATION="nice -n ${NICELEVEL} ${COMMAND}"
  3313. PATH='/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/bin:/var/local/pump.io'
  3314. pumpio_start() {
  3315. echo "Starting $SERVICE..."
  3316. su --command "screen -h ${HISTORY} -dmS ${SERVICE} ${INVOCATION}" $USERNAME
  3317. }
  3318. pumpio_stop() {
  3319. echo "Stopping $SERVICE"
  3320. su --command "screen -p 0 -S ${SERVICE} -X stuff "'^C'"" $USERNAME
  3321. }
  3322. #Start-Stop here
  3323. case "$1" in
  3324. start)
  3325. pumpio_start
  3326. ;;
  3327. stop)
  3328. pumpio_stop
  3329. ;;
  3330. restart)
  3331. pumpio_stop
  3332. sleep 10s
  3333. pumpio_start
  3334. ;;
  3335. *)
  3336. echo "Usage: $0 {start|stop|restart}"
  3337. exit 1
  3338. ;;
  3339. esac
  3340. exit 0
  3341. #+END_SRC
  3342. Save and exit. Then enable the daemon and run it.
  3343. #+BEGIN_SRC: bash
  3344. chmod +x /etc/init.d/pumpio
  3345. update-rc.d pumpio defaults
  3346. service pumpio start
  3347. #+END_SRC
  3348. Now visit your pump.io site by navigating to:
  3349. https://mypumpiodomainname.com
  3350. and add a new user. If you wish this to be a single user node not open to the general public (including spammers and sockpuppets) then edit */etc/pump.io.json* and set *disableRegistration* to *true*. After making that change restart with the command *service pumpio restart*.
  3351. Once you've set up your user account it's recommended that you don't use the web based user interface and instead use a native client such as [[http://jancoding.wordpress.com/dianara/][Dianara]] or Pumpa. On Ubuntu you can install these via the Software Center. On mobile devices you can install AndStatus via F-Droid.
  3352. A list of pump.io sites can be found at http://pumpstatus.jpope.org. At the time of writing there isn't any public directory and so finding people to follow is really a question of navigating through lists of /following/ or /followers/ (rather like the web before search engines were invented).
  3353. Ensure that data data gets backed up with:
  3354. #+BEGIN_SRC: bash
  3355. printf "\n\n# Redis backup" >> /etc/cron.daily/backup
  3356. printf "\ntar -czvf /var/backups/redis_daily.tar.gz /var/lib/redis/dump.rdb" >> /etc/cron.daily/backup
  3357. printf "\n\n# Redis backup" >> /etc/cron.weekly/backup
  3358. printf "\ncp -f /var/backups/redis_weekly.tar.gz /var/backups/redis_weekly2.tar.gz" >> /etc/cron.weekly/backup
  3359. printf "\ncp -f /var/backups/redis_daily.tar.gz /var/backups/redis_weekly.tar.gz" >> /etc/cron.weekly/backup
  3360. printf "\n\n# Redis backup" >> /etc/cron.monthly/backup
  3361. printf "\ncp -f /var/backups/redis_monthly.tar.gz /var/backups/redis_monthly2.tar.gz" >> /etc/cron.monthly/backup
  3362. printf "\ncp -f /var/backups/redis_weekly.tar.gz /var/backups/redis_monthly.tar.gz" >> /etc/cron.monthly/backup
  3363. printf "\n\n# Pump.io backup" >> /etc/cron.daily/backup
  3364. printf "\ntar -czvf /var/backups/pumpio_daily.tar.gz /var/local/pump.io --exclude /var/local/pump.io/.forever" >> /etc/cron.daily/backup
  3365. printf "\n\n# Pump.io backup" >> /etc/cron.weekly/backup
  3366. printf "\ncp -f /var/backups/pumpio_weekly.tar.gz /var/backups/pumpio_weekly2.tar.gz" >> /etc/cron.weekly/backup
  3367. printf "\ncp -f /var/backups/pumpio_daily.tar.gz /var/backups/pumpio_weekly.tar.gz" >> /etc/cron.weekly/backup
  3368. printf "\n\n# Pump.io backup" >> /etc/cron.monthly/backup
  3369. printf "\ncp -f /var/backups/pumpio_monthly.tar.gz /var/backups/pumpio_monthly2.tar.gz" >> /etc/cron.monthly/backup
  3370. printf "\ncp -f /var/backups/pumpio_weekly.tar.gz /var/backups/pumpio_monthly.tar.gz" >> /etc/cron.monthly/backup
  3371. #+END_SRC
  3372. At the time of writing creating backups of the pump.io database is critically important, because regenerating the database or moving to a different databank type causes you to be /permanently banned/ from the pump.io network unless you change your domain name (which may not always be an available option).
  3373. ** Install Gopher
  3374. *** Server setup
  3375. 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.
  3376. To set up a gopher server:
  3377. #+BEGIN_SRC: bash
  3378. apt-get install build-essential
  3379. cd /tmp
  3380. wget http://freedombone.uk.to/geomyidae-current.tgz
  3381. #+END_SRC
  3382. Verify the download:
  3383. #+BEGIN_SRC: bash
  3384. sha256sum geomyidae-current.tgz
  3385. 162f55ab059ab0a9be8e840497795293bbd51c34b1f4564dcdf3f0ddd5c0db31 geomyidae-current.tgz
  3386. #+END_SRC
  3387. Then extract and install it.
  3388. #+BEGIN_SRC: bash
  3389. tar -xzvf geomyidae-current.tgz
  3390. cd geomyidae-*
  3391. make
  3392. make install
  3393. mkdir -p /var/gopher
  3394. #+END_SRC
  3395. 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.
  3396. #+BEGIN_SRC: bash
  3397. editor /etc/init.d/gopher
  3398. #+END_SRC
  3399. Enter the following:
  3400. #+BEGIN_SRC: bash
  3401. #! /bin/sh
  3402. ### BEGIN INIT INFO
  3403. # Provides: gopher
  3404. # Required-Start: $remote_fs $syslog
  3405. # Required-Stop: $remote_fs $syslog
  3406. # Default-Start: 2 3 4 5
  3407. # Default-Stop: 0 1 6
  3408. # Short-Description: Gopher daemon
  3409. # Description: Gopher daemon
  3410. ### END INIT INFO
  3411. # Do NOT "set -e"
  3412. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  3413. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  3414. DESC="Gopher daemon"
  3415. NAME=geomyidae
  3416. DAEMON=/usr/bin/$NAME
  3417. DAEMON_ARGS="-l /var/log/geomyidae.log -b /var/gopher -p 70"
  3418. PIDFILE=/var/run/$NAME.pid
  3419. SCRIPTNAME=/etc/init.d/$NAME
  3420. # Exit if the package is not installed
  3421. [ -x "$DAEMON" ] || exit 0
  3422. # Read configuration variable file if it is present
  3423. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  3424. # Load the VERBOSE setting and other rcS variables
  3425. . /lib/init/vars.sh
  3426. # Define LSB log_* functions.
  3427. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
  3428. # and status_of_proc is working.
  3429. . /lib/lsb/init-functions
  3430. #
  3431. # Function that starts the daemon/service
  3432. #
  3433. do_start()
  3434. {
  3435. # Return
  3436. # 0 if daemon has been started
  3437. # 1 if daemon was already running
  3438. # 2 if daemon could not be started
  3439. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
  3440. || return 1
  3441. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
  3442. $DAEMON_ARGS \
  3443. || return 2
  3444. # Add code here, if necessary, that waits for the process to be ready
  3445. # to handle requests from services started subsequently which depend
  3446. # on this one. As a last resort, sleep for some time.
  3447. }
  3448. #
  3449. # Function that stops the daemon/service
  3450. #
  3451. do_stop()
  3452. {
  3453. # Return
  3454. # 0 if daemon has been stopped
  3455. # 1 if daemon was already stopped
  3456. # 2 if daemon could not be stopped
  3457. # other if a failure occurred
  3458. start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
  3459. RETVAL="$?"
  3460. [ "$RETVAL" = 2 ] && return 2
  3461. # Wait for children to finish too if this is a daemon that forks
  3462. # and if the daemon is only ever run from this initscript.
  3463. # If the above conditions are not satisfied then add some other code
  3464. # that waits for the process to drop all resources that could be
  3465. # needed by services started subsequently. A last resort is to
  3466. # sleep for some time.
  3467. start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
  3468. [ "$?" = 2 ] && return 2
  3469. # Many daemons don't delete their pidfiles when they exit.
  3470. rm -f $PIDFILE
  3471. return "$RETVAL"
  3472. }
  3473. #
  3474. # Function that sends a SIGHUP to the daemon/service
  3475. #
  3476. do_reload() {
  3477. #
  3478. # If the daemon can reload its configuration without
  3479. # restarting (for example, when it is sent a SIGHUP),
  3480. # then implement that here.
  3481. #
  3482. start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
  3483. return 0
  3484. }
  3485. case "$1" in
  3486. start)
  3487. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  3488. do_start
  3489. case "$?" in
  3490. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  3491. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  3492. esac
  3493. ;;
  3494. stop)
  3495. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  3496. do_stop
  3497. case "$?" in
  3498. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  3499. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  3500. esac
  3501. ;;
  3502. status)
  3503. status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  3504. ;;
  3505. #reload|force-reload)
  3506. #
  3507. # If do_reload() is not implemented then leave this commented out
  3508. # and leave 'force-reload' as an alias for 'restart'.
  3509. #
  3510. #log_daemon_msg "Reloading $DESC" "$NAME"
  3511. #do_reload
  3512. #log_end_msg $?
  3513. #;;
  3514. restart|force-reload)
  3515. #
  3516. # If the "reload" option is implemented then remove the
  3517. # 'force-reload' alias
  3518. #
  3519. log_daemon_msg "Restarting $DESC" "$NAME"
  3520. do_stop
  3521. case "$?" in
  3522. 0|1)
  3523. do_start
  3524. case "$?" in
  3525. 0) log_end_msg 0 ;;
  3526. 1) log_end_msg 1 ;; # Old process is still running
  3527. *) log_end_msg 1 ;; # Failed to start
  3528. esac
  3529. ;;
  3530. *)
  3531. # Failed to stop
  3532. log_end_msg 1
  3533. ;;
  3534. esac
  3535. ;;
  3536. *)
  3537. #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  3538. echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
  3539. exit 3
  3540. ;;
  3541. esac
  3542. :
  3543. #+END_SRC
  3544. Save and exit. Then start the gopher service.
  3545. #+BEGIN_SRC: bash
  3546. chmod +x /etc/init.d/gopher
  3547. update-rc.d gopher defaults
  3548. service gopher start
  3549. #+END_SRC
  3550. 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:
  3551. #+BEGIN_SRC: bash
  3552. gopher://mydomainname.com
  3553. #+END_SRC
  3554. There is a browser addon for Gopher called "overbite". Installing that should enable you to view your site.
  3555. *** A phlogging script
  3556. A phlog is the gopher equivalent of a blog on the web. You can create a script which makes phlogging easy.
  3557. #+BEGIN_SRC: bash
  3558. editor /usr/bin/mkphlog
  3559. #+END_SRC
  3560. Add the following:
  3561. #+BEGIN_SRC: bash
  3562. #!/bin/sh
  3563. # mkphlog - a utility to ease the creation of phlogs.
  3564. # Organizes phlog posts in separate directories.
  3565. # Created by octotep; anyone can distribute, modify, and
  3566. # share this file however they please.
  3567. #
  3568. # Version 0.3
  3569. #
  3570. # Modified by Bob Mottram
  3571. #
  3572. # Please note, all date strings are in the form of mm/dd/yy(yy)
  3573. # The base of the entire gopher site.
  3574. gopherRoot="/var/gopher"
  3575. # The name of the phlog directory (contained in $gopherHome)
  3576. phlogDirName="phlog"
  3577. # Default editor, unless the user has one specified in env
  3578. editor=${EDITOR:-emacs}
  3579. # Default timezone, unless the user has one specified in env
  3580. TZ=${TZ:-UTC}
  3581. # Tells the script how many lines the title of the main page spans.
  3582. # Used to insert the newest post at the top.
  3583. # Titles created by mkphlog are 3 lines.
  3584. # Isn't used if $addTitleToMain is false
  3585. titleLineCount=3
  3586. entryDate=`date +%Y-%m-%d`
  3587. # Creates the phlog directory if it dosen't already exist.
  3588. CreatePhlogDir() {
  3589. mkdir $phlogDirName
  3590. chmod 755 $phlogDirName
  3591. cd $phlogDirName
  3592. echo "Phlog directory created."
  3593. }
  3594. # Updates the main phlog listing
  3595. UpdatePhlogListing() {
  3596. # Just in case the user didn't specify a title
  3597. if [ "$postTitleAns" = "" ] ; then
  3598. echo -n "Do you want to create a blank post? (y/n) "
  3599. read blankPostAns
  3600. case $blankPostAns in
  3601. y* | Y* ) $postTitleAns="New Post" ;;
  3602. n* | N* ) echo "Goodbye, then." ; exit 1 ;;
  3603. * ) exit 1 ;;
  3604. esac
  3605. fi
  3606. cd $gopherRoot/$phlogDirName/
  3607. title2=$(echo "${postTitleAns}" | tr " " _)
  3608. postfilename="${entryDate}_${title2}.txt"
  3609. touch ${postfilename}
  3610. echo $postTitleAns >> ${postfilename}
  3611. date "+%A %b %e %l:%M:%S %Y" >> ${postfilename}
  3612. echo "------------------------------" >> ${postfilename}
  3613. echo >> ${postfilename}
  3614. }
  3615. if [ -d $gopherRoot ] ; then
  3616. cd $gopherRoot
  3617. else
  3618. echo "You don't have a gopherspace set-up. Please run the gopher server setup instructions."
  3619. exit 1
  3620. fi
  3621. if [ -d $phlogDirName ] ; then
  3622. cd $phlogDirName
  3623. else
  3624. echo -n "Do you want to create a phlog directory? (y/n) "
  3625. read phlogDirAns
  3626. case $phlogDirAns in
  3627. y* | Y* ) CreatePhlogDir ;;
  3628. n* | N* ) exit 1 ;;
  3629. * ) exit 1 ;;
  3630. esac
  3631. fi
  3632. echo -n "Would you like to create a phlog entry for today? (y/n) "
  3633. read phlogAns
  3634. case $phlogAns in
  3635. y* | Y* ) echo "Creating today's phlog entry..." ;;
  3636. n* | N* ) exit 0 ;;
  3637. * ) exit 1 ;;
  3638. esac
  3639. # Make sure there isn't a post for that day, lest we overwrite it.
  3640. if [ ! -d $entryDate ]; then
  3641. echo -n "Title: "
  3642. read postTitleAns
  3643. title2=$(echo "${postTitleAns}" | tr " " _)
  3644. postfilename="${entryDate}_${title2}.txt"
  3645. touch ${postfilename}
  3646. chmod 644 ${postfilename}
  3647. UpdatePhlogListing
  3648. echo -n "Would you like to edit the post with $editor? (y/n) "
  3649. read editorAns
  3650. case $editorAns in
  3651. y* | Y* ) $editor $gopherRoot/$phlogDirName/${postfilename} ;;
  3652. n* | N* ) exit 0 ;;
  3653. * ) exit 0 ;;
  3654. esac
  3655. rm $gopherRoot/$phlogDirName/${postfilename}~
  3656. else
  3657. echo "There is already a post for today."
  3658. echo -n "Would you like to edit the post with $editor? (y/n) "
  3659. read editorAns
  3660. case $editorAns in
  3661. y* | Y* ) $editor $gopherRoot/$phlogDirName/$entryDate*.txt ;;
  3662. n* | N* ) exit 0 ;;
  3663. * ) exit 1 ;;
  3664. esac
  3665. rm $gopherRoot/$phlogDirName/${postfilename}.txt~
  3666. fi
  3667. exit 0
  3668. #+END_SRC
  3669. Save and exit.
  3670. #+BEGIN_SRC: bash
  3671. chmod +x /usr/bin/mkphlog
  3672. #+END_SRC
  3673. Now entering the command /mkphlog/ will allow you to create a phlog entry.
  3674. ** Install Owncloud
  3675. #+BEGIN_VERSE
  3676. /It's not water vapour/
  3677. -- Larry Ellison
  3678. #+END_VERSE
  3679. 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.
  3680. *** Server Installation
  3681. Install some dependencies:
  3682. #+BEGIN_SRC: bash
  3683. apt-get install apache2 php5 php5-gd php-xml-parser php5-intl
  3684. apt-get install php5-sqlite php5-mysql smbclient curl libcurl3 php5-curl
  3685. #+END_SRC
  3686. 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.
  3687. #+BEGIN_SRC: bash
  3688. a2dismod php5filter
  3689. apt-get install libapache2-mod-php5
  3690. #+END_SRC
  3691. Ensure that the size of files which may be uploaded or downloaded is large enough.
  3692. #+BEGIN_SRC: bash
  3693. editor /etc/php5/apache2/php.ini
  3694. #+END_SRC
  3695. Set the following:
  3696. #+BEGIN_SRC: bash
  3697. upload_max_filesize = 512M
  3698. post_max_size = 512M
  3699. #+END_SRC
  3700. Save and exit, then edit your Apache configuration.
  3701. #+BEGIN_SRC: bash
  3702. export HOSTNAME=mydomainname.com
  3703. editor /etc/apache2/sites-available/$HOSTNAME
  3704. #+END_SRC
  3705. 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.
  3706. #+BEGIN_SRC: bash
  3707. <Directory /var/www/mydomainname.com/htdocs/owncloud>
  3708. Options Indexes FollowSymLinks MultiViews
  3709. AllowOverride All
  3710. Order allow,deny
  3711. allow from all
  3712. </Directory>
  3713. #+END_SRC
  3714. To ensure that nobody logs in insecurely add the following to the 80 VirtualHost section.
  3715. #+BEGIN_SRC: bash
  3716. <Directory /var/www/mydomainname.com/htdocs/owncloud>
  3717. deny from all
  3718. </Directory>
  3719. #+END_SRC
  3720. Save and exit, then restart apache.
  3721. #+BEGIN_SRC: bash
  3722. service apache2 restart
  3723. #+END_SRC
  3724. Download owncloud.
  3725. #+BEGIN_SRC: bash
  3726. cd /tmp
  3727. wget http://freedombone.uk.to/owncloud.tar.bz2
  3728. #+END_SRC
  3729. Verify the download:
  3730. #+BEGIN_SRC: bash
  3731. sha256sum owncloud.tar.bz2
  3732. 92b53fdfa7c4165b83dd2f8447f63928454a5815d08ff2d6165dd1a8969ecbe1 owncloud.tar.bz2
  3733. #+END_SRC
  3734. Extract the archive. This may take a couple of minutes, so don't be alarmed that the system has crashed.
  3735. #+BEGIN_SRC: bash
  3736. export HOSTNAME=mydomainname.com
  3737. tar -xjf owncloud.tar.bz2
  3738. #+END_SRC
  3739. Move the extracted files to your site and set file permissions.
  3740. #+BEGIN_SRC: bash
  3741. cp -r owncloud /var/www/$HOSTNAME/htdocs
  3742. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud/apps
  3743. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud/config
  3744. chown www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud
  3745. #+END_SRC
  3746. Edit the htaccess file for Owncloud.
  3747. #+BEGIN_SRC: bash
  3748. editor /var/www/$HOSTNAME/htdocs/owncloud/.htaccess
  3749. #+END_SRC
  3750. Set the following.
  3751. #+BEGIN_SRC: bash
  3752. php_value upload_max_filesize 512M
  3753. php_value post_max_size 512M
  3754. php_value memory_limit 32M
  3755. #+END_SRC
  3756. Save and exit.
  3757. With a web browser visit your domain (mydomainname.com/owncloud) and enter an administrator username and password.
  3758. *** Owncloud on Android
  3759. 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.
  3760. ** Install a Wiki
  3761. #+BEGIN_VERSE
  3762. /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./
  3763. -- Tom Barbalet
  3764. #+END_VERSE
  3765. Dokuwiki is based upon flat files, and so is easy to move from one server to another without a lot of database complications.
  3766. Download the wiki.
  3767. #+BEGIN_SRC: bash
  3768. cd /tmp
  3769. wget http://freedombone.uk.to/dokuwiki.tgz
  3770. #+END_SRC
  3771. Verify it.
  3772. #+BEGIN_SRC: bash
  3773. sha256sum dokuwiki.tgz
  3774. 6b126f90979463d9ddaa74acc6f96aa230cfdc789946f241c3646086d9574be8 dokuwiki.tgz
  3775. #+END_SRC
  3776. Then extract and install it.
  3777. #+BEGIN_SRC: bash
  3778. export HOSTNAME=mywikidomainname.com
  3779. tar -xzvf dokuwiki.tgz
  3780. mv /var/www/$HOSTNAME/htdocs /var/www/$HOSTNAME/htdocs_old
  3781. mv dokuwiki /var/www/$HOSTNAME/htdocs
  3782. #+END_SRC
  3783. Edit the Apache configuration for your wiki site.
  3784. #+BEGIN_SRC: bash
  3785. editor /etc/apache2/sites-available/$HOSTNAME
  3786. #+END_SRC
  3787. The settings should look something like the following. Replace /mywikidomainname.com/ with your wiki domain name.
  3788. #+BEGIN_SRC: bash
  3789. <VirtualHost *:80>
  3790. ServerAdmin myusername@mywikidomainname.com
  3791. ServerName mydomainname.com
  3792. DocumentRoot /var/www/mywikidomainname.com/htdocs
  3793. <Directory /var/www/mywikidomainname.com/htdocs>
  3794. order deny,allow
  3795. allow from all
  3796. </Directory>
  3797. <LocationMatch "/(data|conf|bin|inc)/">
  3798. order allow,deny
  3799. deny from all
  3800. satisfy all
  3801. </LocationMatch>
  3802. <Directory />
  3803. Options FollowSymLinks
  3804. AllowOverride All
  3805. </Directory>
  3806. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  3807. <Directory "/usr/lib/cgi-bin">
  3808. AllowOverride All
  3809. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  3810. Order allow,deny
  3811. Allow from all
  3812. </Directory>
  3813. ErrorLog ${APACHE_LOG_DIR}/error.log
  3814. # Possible values include: debug, info, notice, warn, error, crit,
  3815. # alert, emerg.
  3816. LogLevel error
  3817. CustomLog ${APACHE_LOG_DIR}/access.log combined
  3818. </VirtualHost>
  3819. <IfModule mod_ssl.c>
  3820. <VirtualHost *:443>
  3821. ServerAdmin myusername@mywikidomainname.com
  3822. ServerName mywikidomainname.com
  3823. DocumentRoot /var/www/mywikidomainname.com/htdocs
  3824. <Directory /var/www/mywikidomainname.com/htdocs>
  3825. order deny,allow
  3826. allow from all
  3827. </Directory>
  3828. <LocationMatch "/(data|conf|bin|inc)/">
  3829. order allow,deny
  3830. deny from all
  3831. satisfy all
  3832. </LocationMatch>
  3833. <Directory />
  3834. Options FollowSymLinks
  3835. AllowOverride All
  3836. </Directory>
  3837. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  3838. <Directory "/usr/lib/cgi-bin">
  3839. AllowOverride All
  3840. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  3841. Order allow,deny
  3842. Allow from all
  3843. </Directory>
  3844. ErrorLog ${APACHE_LOG_DIR}/error.log
  3845. # Possible values include: debug, info, notice, warn, error, crit,
  3846. # alert, emerg.
  3847. LogLevel error
  3848. CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
  3849. # SSL Engine Switch:
  3850. # Enable/Disable SSL for this virtual host.
  3851. SSLEngine on
  3852. # A self-signed certificate
  3853. SSLCertificateFile /etc/ssl/certs/mydomainname.com.crt
  3854. SSLCertificateKeyFile /etc/ssl/private/mydomainname.com.key
  3855. # Options based on bettercrypto.org
  3856. SSLProtocol All -SSLv2 -SSLv3
  3857. SSLHonorCipherOrder On
  3858. SSLCompression off
  3859. 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
  3860. # SSL Engine Options:
  3861. # Set various options for the SSL engine.
  3862. # o FakeBasicAuth:
  3863. # Translate the client X.509 into a Basic Authorisation. This means that
  3864. # the standard Auth/DBMAuth methods can be used for access control. The
  3865. # user name is the `one line' version of the client's X.509 certificate.
  3866. # Note that no password is obtained from the user. Every entry in the user
  3867. # file needs this password: `xxj31ZMTZzkVA'.
  3868. # o ExportCertData:
  3869. # This exports two additional environment variables: SSL_CLIENT_CERT and
  3870. # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
  3871. # server (always existing) and the client (only existing when client
  3872. # authentication is used). This can be used to import the certificates
  3873. # into CGI scripts.
  3874. # o StdEnvVars:
  3875. # This exports the standard SSL/TLS related `SSL_*' environment variables.
  3876. # Per default this exportation is switched off for performance reasons,
  3877. # because the extraction step is an expensive operation and is usually
  3878. # useless for serving static content. So one usually enables the
  3879. # exportation for CGI and SSI requests only.
  3880. # o StrictRequire:
  3881. # This denies access when "SSLRequireSSL" or "SSLRequire" applied even
  3882. # under a "Satisfy any" situation, i.e. when it applies access is denied
  3883. # and no other module can change it.
  3884. # o OptRenegotiate:
  3885. # This enables optimized SSL connection renegotiation handling when SSL
  3886. # directives are used in per-directory context.
  3887. #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
  3888. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  3889. SSLOptions +StdEnvVars
  3890. </FilesMatch>
  3891. <Directory /usr/lib/cgi-bin>
  3892. SSLOptions +StdEnvVars
  3893. </Directory>
  3894. # SSL Protocol Adjustments:
  3895. # The safe and default but still SSL/TLS standard compliant shutdown
  3896. # approach is that mod_ssl sends the close notify alert but doesn't wait for
  3897. # the close notify alert from client. When you need a different shutdown
  3898. # approach you can use one of the following variables:
  3899. # o ssl-unclean-shutdown:
  3900. # This forces an unclean shutdown when the connection is closed, i.e. no
  3901. # SSL close notify alert is send or allowed to received. This violates
  3902. # the SSL/TLS standard but is needed for some brain-dead browsers. Use
  3903. # this when you receive I/O errors because of the standard approach where
  3904. # mod_ssl sends the close notify alert.
  3905. # o ssl-accurate-shutdown:
  3906. # This forces an accurate shutdown when the connection is closed, i.e. a
  3907. # SSL close notify alert is send and mod_ssl waits for the close notify
  3908. # alert of the client. This is 100% SSL/TLS standard compliant, but in
  3909. # practice often causes hanging connections with brain-dead browsers. Use
  3910. # this only for browsers where you know that their SSL implementation
  3911. # works correctly.
  3912. # Notice: Most problems of broken clients are also related to the HTTP
  3913. # keep-alive facility, so you usually additionally want to disable
  3914. # keep-alive for those clients, too. Use variable "nokeepalive" for this.
  3915. # Similarly, one has to force some clients to use HTTP/1.0 to workaround
  3916. # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
  3917. # "force-response-1.0" for this.
  3918. BrowserMatch "MSIE [2-6]" \
  3919. nokeepalive ssl-unclean-shutdown \
  3920. downgrade-1.0 force-response-1.0
  3921. # MSIE 7 and newer should be able to use keepalive
  3922. BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  3923. </VirtualHost>
  3924. </IfModule>
  3925. #+END_SRC
  3926. Enable your site with:
  3927. #+BEGIN_SRC: bash
  3928. a2ensite
  3929. #+END_SRC
  3930. then select the domain name and reload.
  3931. #+BEGIN_SRC: bash
  3932. service apache2 reload
  3933. #+END_SRC
  3934. and alter permissions:
  3935. #+BEGIN_SRC: bash
  3936. chmod -R 755 /var/www/$HOSTNAME/htdocs
  3937. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs
  3938. #+END_SRC
  3939. Open a browser and visit http://$HOSTNAME/install.php, then fill out the details. Once everything has been accepted without errors:
  3940. #+BEGIN_SRC: bash
  3941. rm /var/www/$HOSTNAME/htdocs/install.php
  3942. #+END_SRC
  3943. Add a few extra mime types:
  3944. #+BEGIN_SRC: bash
  3945. editor /var/www/$HOSTNAME/htdocs/conf/mime.conf
  3946. #+END_SRC
  3947. Append the following:
  3948. #+BEGIN_SRC: bash
  3949. ogv video/ogg
  3950. mp4 video/mp4
  3951. webm video/webm
  3952. #+END_SRC
  3953. Save and exit.
  3954. 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*.
  3955. Now you can visit your wiki and begin editing.
  3956. ** Install Bitmessage
  3957. #+BEGIN_VERSE
  3958. /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/
  3959. -- Edward J. Snowden, testimony to the EU parliament
  3960. #+END_VERSE
  3961. *** A new kind of Email
  3962. [[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.
  3963. 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.
  3964. Installing Bitmessage as a daemon will increase the size of the network, and therefore the level of security for all users.
  3965. *** The Daemon
  3966. Install from the current source code.
  3967. #+BEGIN_SRC: bash
  3968. apt-get install python screen
  3969. cd /tmp
  3970. git clone https://github.com/Bitmessage/PyBitmessage.git
  3971. cd PyBitmessage
  3972. make install
  3973. #+END_SRC
  3974. Now create the daemon.
  3975. #+BEGIN_SRC: bash
  3976. editor /etc/init.d/pybitmessage
  3977. #+END_SRC
  3978. Add the following text:
  3979. #+BEGIN_SRC: bash
  3980. #!/bin/bash
  3981. # /etc/init.d/bitmessage
  3982. ### BEGIN INIT INFO
  3983. # Provides: pybitmessage
  3984. # Required-Start: $remote_fs $syslog
  3985. # Required-Stop: $remote_fs $syslog
  3986. # Default-Start: 2 3 4 5
  3987. # Default-Stop: 0 1 6
  3988. # Short-Description: starts bitmessage as a background daemon, suitable for servers
  3989. # Description: This file should be used to construct scripts to be
  3990. # placed in /etc/init.d.
  3991. ### END INIT INFO
  3992. # Author: Super-Nathan <BM-Gu2k3Wy2hpTMYBxSoM2937SPcuU6xzEj>
  3993. #Settings
  3994. SERVICE='pybitmessage'
  3995. LOGFILE='/dev/null' # this disables logging
  3996. # LOGFILE='/var/log/bitmessage.log' # comment out the above line and un-comment this line to save a log
  3997. COMMAND="python bitmessagemain.py > $LOGFILE"
  3998. USERNAME='bitmsg'
  3999. NICELEVEL=19 # from 0-19 the bigger the number, the less the impact on system resources
  4000. HISTORY=1024
  4001. PBM_LOCATION="/usr/local/share/pybitmessage"
  4002. INVOCATION="nice -n ${NICELEVEL} ${COMMAND}"
  4003. PATH='/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl:/sbin:/usr/sbin:/bin:/usr/local/share/pybitmessage'
  4004. bm_start() {
  4005. echo "Starting $SERVICE..."
  4006. cd ${PBM_LOCATION}
  4007. su --command "screen -h ${HISTORY} -dmS ${SERVICE} ${INVOCATION}" $USERNAME
  4008. }
  4009. bm_stop() {
  4010. echo "Stopping $SERVICE"
  4011. su --command "screen -p 0 -S ${SERVICE} -X stuff "'^C'"" $USERNAME
  4012. }
  4013. #Start-Stop here
  4014. case "$1" in
  4015. start)
  4016. bm_start
  4017. ;;
  4018. stop)
  4019. bm_stop
  4020. ;;
  4021. restart)
  4022. bm_stop
  4023. sleep 60s
  4024. bm_start
  4025. ;;
  4026. *)
  4027. echo "Usage: $0 {start|stop|restart}"
  4028. exit 1
  4029. ;;
  4030. esac
  4031. exit 0
  4032. #+END_SRC
  4033. Save and exit.
  4034. 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.
  4035. #+BEGIN_SRC: bash
  4036. adduser bitmsg
  4037. #+END_SRC
  4038. Create a /keys.dat/ file which is used to configure Bitmessage.
  4039. #+BEGIN_SRC: bash
  4040. mkdir /home/bitmsg/.config
  4041. mkdir /home/bitmsg/.config/PyBitmessage
  4042. editor /home/bitmsg/.config/PyBitmessage/keys.dat
  4043. #+END_SRC
  4044. Add the following:
  4045. #+BEGIN_SRC: bash
  4046. [bitmessagesettings]
  4047. settingsversion = 8
  4048. port = 8444
  4049. timeformat = %%a, %%d %%b %%Y %%I:%%M %%p
  4050. blackwhitelist = black
  4051. startonlogon = False
  4052. minimizetotray = False
  4053. showtraynotifications = True
  4054. startintray = False
  4055. socksproxytype = none
  4056. sockshostname = localhost
  4057. socksport = 9050
  4058. socksauthentication = False
  4059. sockslisten = False
  4060. socksusername =
  4061. sockspassword =
  4062. keysencrypted = false
  4063. messagesencrypted = false
  4064. defaultnoncetrialsperbyte = 640
  4065. defaultpayloadlengthextrabytes = 14000
  4066. minimizeonclose = false
  4067. maxacceptablenoncetrialsperbyte = 0
  4068. maxacceptablepayloadlengthextrabytes = 0
  4069. userlocale = system
  4070. useidenticons = True
  4071. identiconsuffix = re9E9UtSEaWD
  4072. replybelow = False
  4073. stopresendingafterxdays = 4
  4074. stopresendingafterxmonths =
  4075. namecoinrpctype = namecoind
  4076. namecoinrpchost = localhost
  4077. namecoinrpcuser =
  4078. namecoinrpcpassword =
  4079. namecoinrpcport = 8336
  4080. sendoutgoingconnections = True
  4081. willinglysendtomobile = False
  4082. daemon = true
  4083. #+END_SRC
  4084. Save and exit. Then enable the daemon and run it.
  4085. #+BEGIN_SRC: bash
  4086. rm -f /tmp/-usr-local-share-pybitmessage-*.lock
  4087. chown -R bitmsg:bitmsg /home/bitmsg
  4088. chmod +x /etc/init.d/pybitmessage
  4089. update-rc.d pybitmessage defaults
  4090. service pybitmessage start
  4091. #+END_SRC
  4092. Now open port 8444 on your internet router or firewall and direct it to the BBB.
  4093. *** Using Bitmessage
  4094. 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.
  4095. 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:
  4096. #+BEGIN_SRC: bash
  4097. cd /tmp
  4098. git clone https://github.com/Bitmessage/PyBitmessage.git
  4099. cd PyBitmessage
  4100. make install
  4101. pybitmessage
  4102. #+END_SRC
  4103. ** Overcome restrictive environments
  4104. #+BEGIN_VERSE
  4105. /Censorship reflects a society's lack of confidence in itself. It is a hallmark of an authoritarian regime./
  4106. -- Potter Stewart
  4107. #+END_VERSE
  4108. 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.
  4109. 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.
  4110. #+BEGIN_SRC: bash
  4111. apt-get install shellinabox libapache2-mod-proxy-html
  4112. #+END_SRC
  4113. Update your Apache configuration.
  4114. #+BEGIN_SRC: bash
  4115. export HOSTNAME=mydomainname.com
  4116. editor /etc/apache2/sites-available/$HOSTNAME
  4117. #+END_SRC
  4118. Within the section which begins with *<VirtualHost *:443>* add the following, replacing /mydomainname.com/ with your domain name and /myusername/ with your username.
  4119. #+BEGIN_SRC: bash
  4120. <Location /shell>
  4121. ProxyPass http://localhost:4200/
  4122. Order allow,deny
  4123. Allow from all
  4124. AuthName "Authentication for shellinabox"
  4125. AuthUserFile /home/mydomainname.com/public_html/.htpasswd
  4126. AuthGroupFile /home/mydomainname.com/public_html/.htgroup
  4127. AuthType Basic
  4128. Require group shellinabox
  4129. Require user myusername
  4130. </Location>
  4131. #+END_SRC
  4132. 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.
  4133. #+BEGIN_SRC: bash
  4134. mkdir /home/$HOSTNAME
  4135. mkdir /home/$HOSTNAME/public_html
  4136. htpasswd -c /home/$HOSTNAME/public_html/.htpasswd myusername
  4137. #+END_SRC
  4138. Create a user group.
  4139. #+BEGIN_SRC: bash
  4140. editor /home/$HOSTNAME/public_html/.htgroup
  4141. #+END_SRC
  4142. Add the following:
  4143. #+BEGIN_SRC: bash
  4144. shellinabox: myusername
  4145. #+END_SRC
  4146. Save and exit, then restart Apache.
  4147. #+BEGIN_SRC: bash
  4148. a2enmod proxy_http
  4149. service apache2 restart
  4150. #+END_SRC
  4151. Now with a web browser navigate to https://mydomainname.com/shell and log in.
  4152. 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/.
  4153. ** Set up a mailing list
  4154. #+BEGIN_VERSE
  4155. /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./
  4156. -- Jono Bacon
  4157. #+END_VERSE
  4158. *** Public mailing list
  4159. 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.
  4160. **** Installation
  4161. #+BEGIN_SRC: bash
  4162. export HOSTNAME=mydomainname.com
  4163. apt-get install mailman
  4164. newlist mailman
  4165. #+END_SRC
  4166. Enter an email address for the list administrator and a password.
  4167. #+BEGIN_SRC: bash
  4168. editor /etc/mailman/mm_cfg.py
  4169. #+END_SRC
  4170. Set *MTA=None* and change *http:* to *https:*, then save and exit.
  4171. Add some settings.
  4172. #+BEGIN_SRC: bash
  4173. editor /etc/exim4/conf.d/main/04_mailman_options
  4174. #+END_SRC
  4175. Add the following, replacing /mydomainname.com/ with your domain name.
  4176. #+BEGIN_SRC: bash
  4177. # Mailman macro definitions
  4178. # Home dir for the Mailman installation
  4179. MM_HOME=/var/lib/mailman
  4180. # User and group for Mailman
  4181. MM_UID=list
  4182. MM_GID=list
  4183. #
  4184. # Domains that your lists are in - colon separated list
  4185. # you may wish to add these into local_domains as well
  4186. domainlist mm_domains=mydomainname.com
  4187. # The path of the Mailman mail wrapper script
  4188. MM_WRAP=MM_HOME/mail/mailman
  4189. #
  4190. # The path of the list config file (used as a required file when
  4191. # verifying list addresses)
  4192. MM_LISTCHK=MM_HOME/lists/${lc::$local_part}/config.pck
  4193. #+END_SRC
  4194. Save and exit.
  4195. #+BEGIN_SRC: bash
  4196. editor /etc/exim4/conf.d/main/000_localmacros
  4197. #+END_SRC
  4198. Append the following:
  4199. #+BEGIN_SRC: bash
  4200. SYSTEM_ALIASES_PIPE_TRANSPORT = address_pipe
  4201. SYSTEM_ALIASES_USER = list
  4202. SYSTEM_ALIASES_GROUP = list
  4203. #+END_SRC
  4204. Save and exit.
  4205. #+BEGIN_SRC: bash
  4206. editor /etc/exim4/conf.d/acl/30_exim4-config_check_rcpt
  4207. #+END_SRC
  4208. Append the following, before the final /accept/:
  4209. #+BEGIN_SRC: bash
  4210. # Do callback verification unless Mailman incoming bounce
  4211. deny !local_parts = *-bounces : *-bounces+*
  4212. !verify = sender/callout=30s,defer_ok
  4213. #+END_SRC
  4214. Save and exit.
  4215. #+BEGIN_SRC: bash
  4216. editor
  4217. /etc/exim4/conf.d/router/450_exim4-config_mailman_aliases
  4218. #+END_SRC
  4219. Add the following:
  4220. #+BEGIN_SRC: bash
  4221. mailman:
  4222. driver = accept
  4223. domains = +mm_domains
  4224. require_files = MM_LISTCHK
  4225. local_part_suffix_optional
  4226. local_part_suffix = -admin : \
  4227. -bounces : -bounces+* : \
  4228. -confirm : -confirm+* : \
  4229. -join : -leave : \
  4230. -owner : -request : \
  4231. -subscribe : -unsubscribe
  4232. transport = mailman_transport
  4233. #+END_SRC
  4234. Save and exit.
  4235. #+BEGIN_SRC: bash
  4236. editor /etc/exim4/conf.d/transport/40_exim4-config_mailman_pipe
  4237. #+END_SRC
  4238. Add the following:
  4239. #+BEGIN_SRC: bash
  4240. mailman_transport:
  4241. driver = pipe
  4242. command = MM_WRAP \
  4243. '${if def:local_part_suffix \
  4244. {${sg{$local_part_suffix}{-(\\w+)(\\+.*)?}{\$1}}} \
  4245. {post}}' \
  4246. $local_part
  4247. current_directory = MM_HOME
  4248. home_directory = MM_HOME
  4249. user = MM_UID
  4250. group = MM_GID
  4251. #+END_SRC
  4252. Save and exit.
  4253. #+BEGIN_SRC: bash
  4254. chown root:list /var/lib/mailman/mail/mailman
  4255. update-exim4.conf.template -r
  4256. update-exim4.conf
  4257. service exim4 restart
  4258. editor /etc/apache2/conf.d/mailman
  4259. #+END_SRC
  4260. Add the following:
  4261. #+BEGIN_SRC: bash
  4262. Alias /pipermail /var/lib/mailman/archives/public
  4263. Alias /images/mailman /usr/share/images/mailman
  4264. <directory /var/lib/mailman/archives/public>
  4265. DirectoryIndex index.html
  4266. </directory>
  4267. #+END_SRC
  4268. Save and exit.
  4269. #+BEGIN_SRC: bash
  4270. editor /etc/apache2/sites-available/$HOSTNAME
  4271. #+END_SRC
  4272. Add the following to the 443 section.
  4273. #+BEGIN_SRC: bash
  4274. <Location /mailman>
  4275. Options Indexes FollowSymLinks MultiViews
  4276. Order allow,deny
  4277. Allow from all
  4278. RedirectMatch ^/$ /cgi-bin/mailman/listinfo
  4279. </Location>
  4280. #+END_SRC
  4281. Save and exit.
  4282. #+BEGIN_SRC: bash
  4283. service apache2 restart
  4284. #+END_SRC
  4285. Now add your mailing list. The list name should not include any spaces.
  4286. #+BEGIN_SRC: bash
  4287. newlist mymailinglistname
  4288. #+END_SRC
  4289. With a browser visit https://$HOSTNAME/cgi-bin/mailman/admin/mymailinglistname to configure the mailing list.
  4290. Under *General Options* add an email address for a moderator (could be the same as the administrator) and click *Submit your changes*.
  4291. Under *Privacy Options* set steps required for subscription to *Confirm and approve* and click *Submit your changes*.
  4292. Also change these settings for the account within https://$HOSTNAME/cgi-bin/mailman/admin/mailman
  4293. Then to test that the mailing list works:
  4294. #+BEGIN_SRC: bash
  4295. exim -d+route -bt mymailinglistname@$HOSTNAME
  4296. #+END_SRC
  4297. If everything is working then this shouldn't show any problems.
  4298. **** Using the mailing list
  4299. Direct subscribers towards:
  4300. #+BEGIN_SRC: bash
  4301. https://mydomainname.com/cgi-bin/mailman/listinfo/mymailinglistname
  4302. #+END_SRC
  4303. To administrate the list visit:
  4304. #+BEGIN_SRC: bash
  4305. https://mydomainname.com/cgi-bin/mailman/admin/mymailinglistname
  4306. #+END_SRC
  4307. To add another mailing list:
  4308. #+BEGIN_SRC: bash
  4309. newlist mymailinglistname
  4310. #+END_SRC
  4311. To delete a mailing list:
  4312. #+BEGIN_SRC: bash
  4313. rmlist -a mymailinglistname
  4314. #+END_SRC
  4315. *** Private (encrypted) mailing list
  4316. 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.
  4317. 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.
  4318. **** Installation
  4319. #+BEGIN_SRC: bash
  4320. apt-get install schleuder
  4321. #+END_SRC
  4322. Edit the configuration:
  4323. #+BEGIN_SRC: bash
  4324. editor /etc/schleuder/schleuder.conf
  4325. #+END_SRC
  4326. Set the following parameters, replacing /mydomainname.com/ with your domain name:
  4327. #+BEGIN_SRC: bash
  4328. smtp_port: 465
  4329. superadminaddr: root@mydomainname.com
  4330. #+END_SRC
  4331. Save and exit.
  4332. Get your GPG public key, replacing /myGPGkeyID/ with your GPG key ID:
  4333. #+BEGIN_SRC: bash
  4334. export MYKEYID=myGPGkeyID
  4335. gpg --search-keys $MYKEYID
  4336. gpg --output /tmp/mypublickey.txt --armor --export $MYKEYID
  4337. #+END_SRC
  4338. 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.
  4339. #+BEGIN_SRC: bash
  4340. export MAILINGLISTNAME=mailinglistname
  4341. export MYUSERNAME=myusername
  4342. export HOSTNAME=mydomainname.com
  4343. export EMAILADDRESS=$MYUSERNAME@$HOSTNAME
  4344. schleuder-newlist $MAILINGLISTNAME@$HOSTNAME -realname "mailing list name" -adminaddress $EMAILADDRESS -initmember $EMAILADDRESS -initmemberkey /tmp/mypublickey.txt -nointeractive
  4345. #+END_SRC
  4346. Now add a mailing list rule:
  4347. #+BEGIN_SRC: bash
  4348. emailrule $MYUSERNAME $MAILINGLISTNAME@$HOSTNAME $MAILINGLISTNAME
  4349. #+END_SRC
  4350. Edit your Mutt configuration.
  4351. #+BEGIN_SRC: bash
  4352. editor /home/$MYUSERNAME/.muttrc
  4353. #+END_SRC
  4354. Search for the /mailboxes/ parameter and add "=mailinglistname". For example:
  4355. #+BEGIN_SRC: bash
  4356. mailboxes = =Sent =Drafts =mailinglistname
  4357. #+END_SRC
  4358. Save and exit.
  4359. Update Exim routing.
  4360. #+BEGIN_SRC: bash
  4361. editor /etc/exim4/conf.d/router/550_exim4-config_schleuder
  4362. #+END_SRC
  4363. Add the following:
  4364. #+BEGIN_SRC: bash
  4365. schleuder:
  4366. debug_print = "R: schleuder for $local_part@$domain"
  4367. driver = accept
  4368. local_part_suffix_optional
  4369. local_part_suffix = +* : -bounce : -sendkey
  4370. domains = +local_domains
  4371. user = schleuder
  4372. group = schleuder
  4373. require_files = schleuder:+/var/lib/schleuder/$domain/${local_part}
  4374. transport = schleuder_transport
  4375. #+END_SRC
  4376. Save and exit.
  4377. #+BEGIN_SRC: bash
  4378. editor /etc/exim4/conf.d/transport/30_exim4-config_schleuder
  4379. #+END_SRC
  4380. Add the following.
  4381. #+BEGIN_SRC: bash
  4382. schleuder_transport:
  4383. debug_print = "T: schleuder_transport for $local_part@$domain"
  4384. driver = pipe
  4385. home_directory = "/var/lib/schleuder/$domain/$local_part"
  4386. command = "/usr/bin/schleuder $local_part@$domain"
  4387. #+END_SRC
  4388. Save and exit.
  4389. #+BEGIN_SRC: bash
  4390. chown -R schleuder:schleuder /var/lib/schleuder
  4391. update-exim4.conf.template -r
  4392. update-exim4.conf
  4393. service exim4 restart
  4394. useradd -d /var/schleuderlists -s /bin/false schleuder
  4395. adduser Debian-exim schleuder
  4396. usermod -a -G mail schleuder
  4397. #+END_SRC
  4398. Test the routing.
  4399. #+BEGIN_SRC: bash
  4400. exim -d -bt mailinglistname@mydomainname.com
  4401. #+END_SRC
  4402. **** Importing the public key of the mailing list
  4403. Before you can use the mailing list you will first need to import its public key. How you do this depends upon which email client you're using.
  4404. ***** Using Mutt
  4405. Send an email to /mailinglistname-sendkey@mydomainname.com/ to have the list public key emailed to you.
  4406. When you receive the email open it and press *CTRL-k* to import it.
  4407. ***** Using Thunderbird
  4408. Send an email to /mailinglistname-sendkey@mydomainname.com/ to have the list public key emailed to you.
  4409. When you receive the email open it, select all the text with *CTRL-a* then *CTRL-c*.
  4410. On the menu select *OpenPGP* followed by *Key Management*.
  4411. You will now see a new menu bar. Select *Edit* followed by *Import keys from clipboard*.
  4412. Click on *Import* followed by *Ok*.
  4413. **** Using the list
  4414. To obtain the public keys of list members send an email to /mailinglistname-request@mydomainname.com/ containing *X-LIST-KEYS* in the message body.
  4415. To add a member: *X-ADD-MEMBER: othermember@otherdomain.net*
  4416. An example of adding a public key to the list:
  4417. #+BEGIN_SRC: bash
  4418. X-ADD-KEY:
  4419. -----BEGIN PGP PUBLIC KEY BLOCK-----
  4420. Version: GnuPG v1.4.9 (GNU/Linux)
  4421. mQGiBEjVO7oRBADQvT6wtD2IzzIiK0NbrcilCKCp4MWb8cYXTXguwPQI6y0Nerz4
  4422. dsK6J0X1Vgeo02tqA4xd3EDK8rdqL2yZfl/2egH8+85R3gDk+kqkfEp4pwCgp6VO
  4423. [...]
  4424. pNlF/qkaWwRb048h+iMrW21EkouLKTDPFkdFbapV2X5KJZIcfhO1zEbwc1ZKF3Ju
  4425. Q9X5GRmY62hz9SCZnsC0jeYAni8OUQV9NXfXlS/vePBUnOL08NQB
  4426. =xTv3
  4427. -----END PGP PUBLIC KEY BLOCK-----
  4428. #+END_SRC
  4429. To get details for a member: *X-GET-MEMBER: othermember@otherdomain.net*
  4430. To delete a member: *X-DELETE-MEMBER: othermember@otherdomain.net*
  4431. To delete a public key: *X-DELETE-KEY: keyID*
  4432. You can unsubscribe from the list with *X-UNSUBSCRIBE* in the message body.
  4433. *** Decentralised mailing list
  4434. 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.
  4435. An alternative is to use a decentralised mailing list, implemented using Bitmessage. On your local machine (not the BBB) you can make a private mailing list which is difficult to censor and where there is no single point of failure. This type of mailing list is known as a "/chan/".
  4436. 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.
  4437. On a Debian based system:
  4438. #+BEGIN_SRC: bash
  4439. sudo apt-get install makepasswd
  4440. #+END_SRC
  4441. or on an RPM based system:
  4442. #+BEGIN_SRC: bash
  4443. sudo yum install makepasswd
  4444. #+END_SRC
  4445. Create a name for your mailing list. This will be a random string.
  4446. #+BEGIN_SRC: bash
  4447. makepasswd -c 40
  4448. #+END_SRC
  4449. Keep a note of this.
  4450. Run the Bitmessage client and on the menu select *File/Join-Create Chan/Create new chan*
  4451. 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.
  4452. 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.
  4453. 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.
  4454. 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.
  4455. ** Install a microblog
  4456. #+BEGIN_VERSE
  4457. /If you want to have more control over how you interact on the web, and regain your freedom, privacy and autonomy from outside interference, you need to start moving towards using programs like GNU Social/
  4458. -- Jason Self
  4459. #+END_VERSE
  4460. For a microblog you will need a separate domain/subdomain, so see [[Setting up a web site]] for details of how to create an Apache configuration for your microblog. If you're using freedns then you will need to create a new subdomain.
  4461. Install some dependencies:
  4462. #+BEGIN_SRC: bash
  4463. apt-get install php5-xcache php-gettext php5-curl php5-gd php5-mysql
  4464. #+END_SRC
  4465. Download GNU Social
  4466. #+BEGIN_SRC: bash
  4467. cd /tmp
  4468. wget http://freedombone.uk.to/gnu-social.tar.gz
  4469. #+END_SRC
  4470. Verify it.
  4471. #+BEGIN_SRC: bash
  4472. sha256sum gnu-social.tar.gz
  4473. 1f886241c7f1a175e7be3cccbcb944ab6c03617fb75aefa4d62d37abed87d2b4
  4474. #+END_SRC
  4475. Extract the files and set permissions on them, where /mydomainname.com/ is your domain name.
  4476. #+BEGIN_SRC: bash
  4477. export HOSTNAME=mydomainname.com
  4478. tar zxf gnu-social.tar.gz
  4479. rm -rf /var/www/$HOSTNAME/htdocs
  4480. mv statusnet-gnu-social /var/www/$HOSTNAME/htdocs
  4481. chmod a+w /var/www/$HOSTNAME/htdocs
  4482. chown www-data:www-data /var/www/$HOSTNAME/htdocs
  4483. chmod a+w /var/www/$HOSTNAME/htdocs/avatar
  4484. chmod a+w /var/www/$HOSTNAME/htdocs/background
  4485. chmod a+w /var/www/$HOSTNAME/htdocs/file
  4486. chmod +x /var/www/$HOSTNAME/htdocs/scripts/maildaemon.php
  4487. #+END_SRC
  4488. Edit the Apache access settings.
  4489. #+BEGIN_SRC: bash
  4490. editor /var/www/$HOSTNAME/htdocs/.htaccess
  4491. #+END_SRC
  4492. Add the following:
  4493. #+BEGIN_SRC: bash
  4494. <IfModule mod_rewrite.c>
  4495. RewriteEngine On
  4496. RewriteBase /
  4497. ## Uncomment these if having trouble with API authentication
  4498. ## when PHP is running in CGI or FastCGI mode.
  4499. #
  4500. #RewriteCond %{HTTP:Authorization} ^(.*)
  4501. #RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
  4502. RewriteCond %{REQUEST_FILENAME} !-f
  4503. RewriteCond %{REQUEST_FILENAME} !-d
  4504. RewriteRule (.*) index.php?p=$1 [L,QSA]
  4505. </IfModule>
  4506. <FilesMatch "\.(ini)">
  4507. Order allow,deny
  4508. </FilesMatch>
  4509. #+END_SRC
  4510. Save and exit, then create a database.
  4511. #+BEGIN_SRC: bash
  4512. mysql -u root -p
  4513. create database gnusocial;
  4514. CREATE USER 'gnusocialadmin'@'localhost' IDENTIFIED BY 'gnusocialpassword';
  4515. GRANT ALL PRIVILEGES ON gnusocial.* TO 'gnusocialadmin'@'localhost';
  4516. quit
  4517. #+END_SRC
  4518. Add the mailer script to the aliases file:
  4519. #+BEGIN_SRC: bash
  4520. editor /etc/aliases
  4521. #+END_SRC
  4522. Add the following, replacing /mydomainname.com/ with your domain name.
  4523. #+BEGIN_SRC: bash
  4524. www-data: root
  4525. *: /var/www/mydomainname.com/htdocs/scripts/maildaemon.php
  4526. #+END_SRC
  4527. Save and exit. Update the aliases by typing:
  4528. #+BEGIN_SRC: bash
  4529. newaliases
  4530. #+END_SRC
  4531. Then with a web browser navigate to:
  4532. https://$HOSTNAME/install.php
  4533. Set a name for the site.
  4534. Server SSL: enable
  4535. Hostname: localhost
  4536. Type: MySql
  4537. Name: gnusocial
  4538. DB username: gnusocialadmin
  4539. DB Password; your gnu social admin password goes here
  4540. Administrator nickname: myusername
  4541. Administrator password: mylongrandompassword
  4542. Subscribe to announcements: ticked
  4543. Site profile: Community
  4544. Press the *Submit* button. It may take a few minutes, so don't be concerned that it has crashed. When the process completes you will see a lot of "Strict standards" warnings which you can ignore.
  4545. Navigate to http://$HOSTNAME/gnusocial and you can then complete the configuration via the *Admin* section on the header bar. Some recommended admin settings are:
  4546. Under the *Site* settings:
  4547. Text limit: 140
  4548. Dupe Limit: 60000
  4549. Under the *User* settings:
  4550. Bio limit: 1000
  4551. Under the *Access* settings:
  4552. /Invite only/ ticked
  4553. Under the License section select a license if you wish. Details for Creative Commons licenses [[https://creativecommons.org/licenses/][can be found here]]. If you only intend to do private microblogging then just leave these settings as they are.
  4554. If you want to invite more users then click on the big button *Invite more colleagues*, then enter their email addresses and hit the *send* button. The invite only configuration which you've just installed is useful because it prevents spammers, or other [[https://en.wikipedia.org/wiki/Joint_Threat_Research_Intelligence_Group]["bad actors"]], from clogging your system with nonsense.
  4555. Edit the config file.
  4556. #+BEGIN_SRC: bash
  4557. editor /var/www/$HOSTNAME/htdocs/config.php
  4558. #+END_SRC
  4559. Change the ssl setting from *always* to *sometimes*, hten save and exit.
  4560. So, you're now microblogging on the open web, with no companies in the middle. Congratulations! To find some other people to connect to you can try searching other nodes listed at http://gnu.io/try/
  4561. When following other GNU Social users enter the URL of your profile. For example, https://mygnusocialdomain/myusername
  4562. ** Install Mediagoblin
  4563. #+BEGIN_VERSE
  4564. /The silos that are the main current points of media sharing are not only vulnerable to attacks on free speech, but also hamper important grassroots economic activity by privileging the interests of a tiny minority over those of most of the world./
  4565. #+END_VERSE
  4566. Mediagoblin allows you to have a YouTube/Soundcloud/Flickr/Picasa type of site to share your pictures, videos or audio files. An advantage of not having any company in the middle is that you can't be arbitrarily censored without any explanation, as seems to frequently occur on YouTube. It is recommended that you use media formats which are not encumbered by patents, such as /ogg/ or /ogv/.
  4567. For a mediagoblin site it is recommended to use a separate domain/subdomain, so see [[Setting up a web site]] for details of how to create an Apache configuration for your microblog. If you're using freedns then you will need to create a new subdomain.
  4568. Install some dependencies.
  4569. #+BEGIN_SRC: bash
  4570. apt-get install git-core python python-dev python-lxml python-imaging python-virtualenv python-gst0.10 libjpeg8-dev sqlite3 libapache2-mod-fcgid gstreamer0.10-plugins-base gstreamer0.10-plugins-bad gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-ffmpeg python-numpy python-scipy libsndfile1-dev
  4571. #+END_SRC
  4572. Create a user, replacing /mymediagoblindomain/ with the domain name for your mediagoblin site.
  4573. #+BEGIN_SRC: bash
  4574. export HOSTNAME=mymediagoblindomain
  4575. adduser mediagoblin
  4576. #+END_SRC
  4577. Give the user a long random password.
  4578. #+BEGIN_SRC: bash
  4579. mkdir -p /srv/$HOSTNAME
  4580. chown -hR mediagoblin:mediagoblin /srv/$HOSTNAME
  4581. su - mediagoblin
  4582. export HOSTNAME=mymediagoblindomain
  4583. cd /srv/$HOSTNAME
  4584. git clone git://gitorious.org/mediagoblin/mediagoblin.git
  4585. cd mediagoblin
  4586. git submodule init
  4587. git submodule update
  4588. virtualenv --system-site-packages .
  4589. ./bin/python setup.py develop
  4590. ./bin/easy_install flup
  4591. cp mediagoblin.ini mediagoblin_local.ini
  4592. cp paste.ini paste_local.ini
  4593. editor mediagoblin_local.ini
  4594. #+END_SRC
  4595. Change *email_sender_address* to your email address and set *email_debug_mode* to false. Also append the following to the bottom of the file, under the *plugins* section.
  4596. #+BEGIN_SRC: bash
  4597. [[mediagoblin.media_types.audio]]
  4598. [[mediagoblin.media_types.video]]
  4599. [[mediagoblin.media_types.stl]]
  4600. #+END_SRC
  4601. Then save and exit.
  4602. #+BEGIN_SRC: bash
  4603. ./bin/pip install scikits.audiolab
  4604. ./bin/gmg dbupdate
  4605. exit # to go back to the root user
  4606. editor /etc/init.d/mediagoblin
  4607. #+END_SRC
  4608. Add the following, replacing /mymediagoblindomain/ with the domain name for your mediagoblin site.
  4609. #+BEGIN_SRC: bash
  4610. #!/bin/bash
  4611. # /etc/init.d/mediagoblin
  4612. ### BEGIN INIT INFO
  4613. # Provides: mediagoblin
  4614. # Required-Start: $remote_fs $syslog
  4615. # Required-Stop: $remote_fs $syslog
  4616. # Default-Start: 2 3 4 5
  4617. # Default-Stop: 0 1 6
  4618. # Short-Description: starts mediagoblin
  4619. # Description: Other methods may work, but I found this the easiest
  4620. ### END INIT INFO
  4621. # Author: Bob Mottram <bob@robotics.uk.to>
  4622. #Settings
  4623. SERVICE='mediagoblin'
  4624. LOGFILE='/srv/mymediagoblindomain/mediagoblin.log'
  4625. COMMAND="./lazyserver.sh > $LOGFILE"
  4626. USERNAME='mediagoblin'
  4627. NICELEVEL=15 # from 0-19 the bigger the number, the less the impact on system resources
  4628. HISTORY=1024
  4629. MG_LOCATION="/srv/mymediagoblindomain/mediagoblin"
  4630. INVOCATION="nice -n ${NICELEVEL} ${COMMAND}"
  4631. PATH='/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl:/sbin:/usr/sbin:/bin'
  4632. mg_start() {
  4633. echo "Starting $SERVICE..."
  4634. cd ${MG_LOCATION}
  4635. su --command "screen -h ${HISTORY} -dmS ${SERVICE} ${INVOCATION}" $USERNAME
  4636. }
  4637. mg_stop() {
  4638. echo "Stopping $SERVICE"
  4639. su --command "screen -p 0 -S ${SERVICE} -X stuff "'^C'"" $USERNAME
  4640. }
  4641. #Start-Stop here
  4642. case "$1" in
  4643. start)
  4644. mg_start
  4645. ;;
  4646. stop)
  4647. mg_stop
  4648. ;;
  4649. restart)
  4650. mg_stop
  4651. sleep 10s
  4652. mg_start
  4653. ;;
  4654. *)
  4655. echo "Usage: $0 {start|stop|restart}"
  4656. exit 1
  4657. ;;
  4658. esac
  4659. exit 0
  4660. #+END_SRC
  4661. Save and exit.
  4662. #+BEGIN_SRC: bash
  4663. chmod +x /etc/init.d/mediagoblin
  4664. update-rc.d mediagoblin defaults
  4665. service mediagoblin start
  4666. #+END_SRC
  4667. Edit the Apache configuration for your mediagoblin site.
  4668. #+BEGIN_SRC: bash
  4669. editor /etc/apache2/sites-available/mymediagoblindomain
  4670. #+END_SRC
  4671. Delete the existing configuration (in Emacs it's CTRL-x h then CTRL-w) and paste the following, replacing /mymediagoblindomain/ with your mediagoblin domain name and /myusername@mydomainname.com/ with your email address.
  4672. #+BEGIN_SRC: bash
  4673. <VirtualHost *:80>
  4674. ServerAdmin myusername@mydomainname.com
  4675. DocumentRoot /srv/mymediagoblindomain/mediagoblin
  4676. ServerName mymediagoblindomain
  4677. <Directory />
  4678. Options FollowSymLinks
  4679. AllowOverride None
  4680. </Directory>
  4681. <Directory /srv/mymediagoblindomain/mediagoblin/>
  4682. Options Indexes FollowSymLinks MultiViews
  4683. AllowOverride All
  4684. Order allow,deny
  4685. allow from all
  4686. </Directory>
  4687. LogLevel warn
  4688. ProxyVia On
  4689. ProxyRequests off
  4690. ProxyPreserveHost on
  4691. ProxyPass / http://localhost:6543/
  4692. ErrorLog "/var/log/apache2/error.log"
  4693. CustomLog "/var/log/apache2/access.log" combined
  4694. RewriteEngine On
  4695. RewriteOptions Inherit
  4696. </VirtualHost>
  4697. #+END_SRC
  4698. Save and exit.
  4699. Now in a browser visit http://mymediagoblindomain and create a user. If you wish this to be a single user installation to prevent a lot of spammers signing up.
  4700. #+BEGIN_SRC: bash
  4701. editor /srv/mymediagoblindomain/mediagoblin/mediagoblin_local.ini
  4702. #+END_SRC
  4703. Then set:
  4704. #+BEGIN_SRC: bash
  4705. allow_registration = false
  4706. #+END_SRC
  4707. Save and exit.
  4708. ** Install Tripwire
  4709. #+BEGIN_VERSE
  4710. /...by the time you get done with all of that, we have a freedom box/
  4711. -- Eben Moglen
  4712. #+END_VERSE
  4713. 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.
  4714. #+BEGIN_SRC: bash
  4715. apt-get install tripwire
  4716. export HOSTNAME=mydomainname.com
  4717. cd /etc/tripwire
  4718. cp arm-local.key $HOSTNAME-local.key
  4719. cp site.key $HOSTNAME-site.key
  4720. tripwire --init
  4721. tripwire --update-policy --secure-mode low /etc/tripwire/twpol.txt
  4722. tripwire --check --interactive
  4723. #+END_SRC
  4724. you will be asked for two passphrases ("site" and "local"). Make a note of these.
  4725. Turn off reporting of changes to system logs.
  4726. #+BEGIN_SRC: bash
  4727. editor /etc/tripwire/twcfg.txt
  4728. #+END_SRC
  4729. Set *SYSLOGREPORTING* to false and comment out the line, then save and exit.
  4730. #+BEGIN_SRC: bash
  4731. editor /etc/tripwire/twpol.txt
  4732. #+END_SRC
  4733. Comment out the line:
  4734. #+BEGIN_SRC: bash
  4735. /var/log -> $(SEC_CONFIG) ;
  4736. #+END_SRC
  4737. Then save and exit.
  4738. If you subsequently install any more packages or make configuration changes then update the policy again with:
  4739. #+BEGIN_SRC: bash
  4740. tripwire --update-policy --secure-mode low /etc/tripwire/twpol.txt
  4741. #+END_SRC
  4742. Also, to look for any rootkits.
  4743. #+BEGIN_SRC: bash
  4744. apt-get install rkhunter
  4745. #+END_SRC
  4746. * Router/Firewall ports
  4747. The following ports on your internet router/firewall should be forwarded to the BBB.
  4748. | Protocol | Port/s |
  4749. |---------------+------------|
  4750. | Gopher | 70 |
  4751. | HTTP | 80 |
  4752. | HTTPS | 443 |
  4753. | IMAP | 143 |
  4754. | IRC SSL | 6670 |
  4755. | SIP | 5060..5061 |
  4756. | SMTP | 25 |
  4757. | SMTPS | 465 |
  4758. | SSH | 22 |
  4759. | XMPP | 5222..5223 |
  4760. | XMPP (server) | 5269 |
  4761. | XMPP (BOSH) | 5280..5281 |
  4762. | Bitmessage | 8444 |
  4763. | Convergence | 8432..8433 |
  4764. * Hints and Tips
  4765. ** Example software sources
  4766. If you get errors when running *apt-get update* then you may need to check your repositories list. Here are examples of repositories within */etc/apt/sources.list*
  4767. *** Beaglebone Black
  4768. #+BEGIN_SRC: bash
  4769. deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free
  4770. deb-src http://ftp.us.debian.org/debian/ wheezy main contrib non-free
  4771. deb http://ftp.us.debian.org/debian/ wheezy-updates main contrib non-free
  4772. deb-src http://ftp.us.debian.org/debian/ wheezy-updates main contrib non-free
  4773. deb http://security.debian.org/ wheezy/updates main contrib non-free
  4774. deb-src http://security.debian.org/ wheezy/updates main contrib non-free
  4775. deb http://ftp.us.debian.org/debian wheezy-backports main contrib non-free
  4776. #+END_SRC
  4777. *** Cubieboard
  4778. #+BEGIN_SRC: bash
  4779. deb http://http.debian.net/debian/ wheezy main contrib non-free
  4780. deb http://http.debian.net/debian/ wheezy-backports main contrib non-free
  4781. deb http://security.debian.org/ wheezy/updates main contrib non-free
  4782. deb http://mirrors.sohu.com/debian/ wheezy main contrib non-free
  4783. deb http://packages.cubian.org/ wheezy main non-free
  4784. deb http://repo.ajenti.org/debian main main debian
  4785. #+END_SRC
  4786. ** Messaging security
  4787. 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.
  4788. ** Moving Domains
  4789. 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:
  4790. #+BEGIN_SRC: bash
  4791. find /var/www/mynewdomain/htdocs -type f -exec sed -i 's@myolddomain@mynewdomain@g' {} \;
  4792. #+END_SRC
  4793. If you're moving the blog to a new domain then you will need to delete the lock file:
  4794. #+BEGIN_SRC: bash
  4795. rm /var/www/myblogdomainname.com/htdocs/fp-content/%%setup.lock
  4796. #+END_SRC
  4797. 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.
  4798. ** MySql foo
  4799. *** Backup all databases
  4800. To back up all mysql databases:
  4801. #+BEGIN_SRC: bash
  4802. mysqldump -u root -p --all-databases --events > /var/backups/databasebackup.sql
  4803. #+END_SRC
  4804. *** Restoring a particular mysql database
  4805. To restore yesterday's friendica backup:
  4806. #+BEGIN_SRC: bash
  4807. mysql -D friendica -o < /var/backups/friendica_daily.sql
  4808. #+END_SRC
  4809. To restore yesterday's mediawiki backup:
  4810. #+BEGIN_SRC: bash
  4811. mysql -D wikidb -o < /var/backups/wikidb_daily.sql
  4812. #+END_SRC
  4813. *** Removing mysql server
  4814. If you manage to screw up sql server completely then it can be fully deleted with:
  4815. #+BEGIN_SRC: bash
  4816. ps aux | grep mysql
  4817. #+END_SRC
  4818. and use /kill -9 <pid>/ to kill all mysql processes.
  4819. #+BEGIN_SRC: bash
  4820. apt-get remove --purge mysql\*
  4821. apt-get clean
  4822. updatedb
  4823. #+END_SRC
  4824. ** Regenerating SSL certificates
  4825. If a security vulnerability arrises which requires you to regenerate your SSL certificates, such as [[http://filippo.io/Heartbleed]["heartbleed"]], then this can be done as follows:
  4826. Obtain the latest updates:
  4827. #+BEGIN_SRC: bash
  4828. apt-get update
  4829. apt-get upgrade
  4830. #+END_SRC
  4831. Run *makecert <domain>* for each of your sites.
  4832. Recreate the XMPP certificate:
  4833. #+BEGIN_SRC: bash
  4834. openssl genrsa -out /etc/ssl/private/xmpp.key 4096
  4835. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  4836. chmod 600 /etc/ssl/private/xmpp.key
  4837. chmod 600 /etc/ssl/certs/xmpp.crt
  4838. chown prosody:prosody /etc/ssl/private/xmpp.key
  4839. chown prosody:prosody /etc/ssl/certs/xmpp.crt
  4840. #+END_SRC
  4841. And regenerate the IRC server keys:
  4842. #+BEGIN_SRC: bash
  4843. openssl genrsa -out /etc/ircd-hybrid/key/ircd.key 4096
  4844. openssl req -new -x509 -key /etc/ircd-hybrid/key/ircd.key -out /etc/ircd-hybrid/key/ircd.pem -days 3650
  4845. chmod 600 /etc/ircd-hybrid/key/ircd.key
  4846. chmod 600 /etc/ircd-hybrid/key/ircd.pem
  4847. #+END_SRC
  4848. As an added precaution you may wish to regenerate your ssh host keys:
  4849. #+BEGIN_SRC: bash
  4850. rm /etc/ssh/ssh_host_*
  4851. dpkg-reconfigure openssh-server
  4852. #+END_SRC
  4853. Then reboot the server with:
  4854. #+BEGIN_SRC: bash
  4855. reboot
  4856. #+END_SRC
  4857. ** Example crontab file
  4858. This is an example of what your crontab file might look like, with the more frequently run tasks at the top. For the two most frequent tasks specific minutes within each hour are given and they're arranged to try to minimise the number of things running simultaneously.
  4859. #+BEGIN_SRC: bash
  4860. # /etc/crontab: system-wide crontab
  4861. # Unlike any other crontab you don't have to run the `crontab'
  4862. # command to install the new version when you edit this file
  4863. # and files in /etc/cron.d. These files also have username fields,
  4864. # that none of the other crontabs do.
  4865. SHELL=/bin/sh
  4866. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  4867. # m h dom mon dow user command
  4868. 10,20,30,40,50 * * * * root /usr/bin/timeout 120 /usr/bin/dynamicdns && /usr/bin/spamfilter myusername
  4869. 15,35,55 * * * * root cd /var/www/mydomainname/htdocs; /usr/bin/timeout 240 /usr/bin/php include/poller.php
  4870. 17 * * * * root cd / && run-parts --report /etc/cron.hourly
  4871. 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
  4872. 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
  4873. 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
  4874. #+END_SRC
  4875. ** Using your own domain
  4876. Suppose that you have bought a domain name (rather than using a free subdomain on freedns) and you want to use that instead.
  4877. Remove any existing nameservers for your domain (or select "custom" nameservers), then add:
  4878. #+BEGIN_SRC: bash
  4879. NS1.AFRAID.ORG
  4880. NS2.AFRAID.ORG
  4881. NS3.AFRAID.ORG
  4882. NS4.AFRAID.ORG
  4883. #+END_SRC
  4884. It might take a few minutes for the above change to take effect. Within freedns click on "Domains" and add your domains (this might only be available to paid members). Make sure that they're marked as "private".
  4885. Select "Subdomains" from the menu on the left then select the MX entry for your domain and change the destination to *10:mydomainname* rather than *10:mail.mydomainname*.
  4886. To route email to one of your freedns domains:
  4887. #+BEGIN_SRC: bash
  4888. editor /etc/mailname
  4889. #+END_SRC
  4890. Add any extra domains which you own, then save and exit.
  4891. #+BEGIN_SRC: bash
  4892. editor /etc/exim4/update-exim4.conf.conf
  4893. #+END_SRC
  4894. Within dc_other_hostnames add your extra domain names, separated by a colon ':' character.
  4895. Save and exit, then restart exim.
  4896. #+BEGIN_SRC: bash
  4897. update-exim4.conf.template -r
  4898. update-exim4.conf
  4899. service exim4 restart
  4900. #+END_SRC
  4901. You should now be able to send an email from /postmaster@mynewdomainname/ and it should arrive in your inbox.
  4902. ** Obtaining an "official" SSL certificate
  4903. You can obtain a free "official" (as in recognised by default by web browsers) SSL certificate from [[https://www.startssl.com/][StartSSL]]. You will first need to have bought a domain name, since it's not possible to obtain one for a freedns subdomain, so see [[Using your own domain]] for details of how to do that. You should also have tested that you can send email to the domain and receive it on the BBB (via Mutt or any other email client).
  4904. When creating a SSL certificate it's important that the private key (the private component of the public/private pair in [[https://en.wikipedia.org/wiki/Public-key_cryptography][public key cryptography]]) be generated on the BBB /and remain there/. Don't generate the private key via the StartSSL certificate wizard because this means that potentially they may retain a copy of it which could then be exfiltrated either via [[https://en.wikipedia.org/wiki/Lavabit][Lavabit]] style methodology, "implants", compromised sysadmins or other "side channel" methods. So that the private key isn't broadcast on the internet we can instead generate a certificate request, which is really just a request for authorisation of a public key.
  4905. Firstly you should have an Apache web site configutaion ready to go. See [[Setting up a web site]] for details.
  4906. Within StartSSL under the validations wizard validate your domain, which means sending an email to it and confirming a code.
  4907. Now we can generate the certificate request as follows.
  4908. #+BEGIN_SRC: bash
  4909. export HOSTNAME=mydomainname.com
  4910. openssl genrsa -out /etc/ssl/private/$HOSTNAME.key 2048
  4911. chown root:ssl-cert /etc/ssl/private/$HOSTNAME.key
  4912. chmod 440 /etc/ssl/private/$HOSTNAME.key
  4913. mkdir /etc/ssl/requests
  4914. #+END_SRC
  4915. Now make a certificate request as follows. You should copy and paste the whole of this, not just line by line.
  4916. #+BEGIN_SRC: bash
  4917. openssl req -new -key /etc/ssl/private/$HOSTNAME.key -out /etc/ssl/requests/$HOSTNAME.csr
  4918. #+END_SRC
  4919. For the email address it's a good idea to use postmaster@mydomainname.
  4920. Use a random 20 character password, and keep a note of it. We'll remove this later.
  4921. View the request with:
  4922. #+BEGIN_SRC: bash
  4923. cat /etc/ssl/requests/$HOSTNAME.csr
  4924. #+END_SRC
  4925. You can then click on "skip" within the StartSSL certificates wizard and copy and paste the encrypted request into the text entry box. A confirmation will be emailed back to you normally within a few hours.
  4926. Log into your StartSSL account and select *Retrieve Certificate* from the *Tool Box* tab. Copy the text.
  4927. #+BEGIN_SRC: bash
  4928. editor /etc/ssl/certs/$HOSTNAME.crt
  4929. #+END_SRC
  4930. Paste the public key, then save and exit. Then on the BBB.
  4931. #+BEGIN_SRC: bash
  4932. mkdir /etc/ssl/roots
  4933. mkdir /etc/ssl/chains
  4934. wget "http://www.startssl.com/certs/ca.pem" --output-document="/etc/ssl/roots/startssl-root.ca"
  4935. wget "http://www.startssl.com/certs/sub.class1.server.ca.pem" --output-document="/etc/ssl/chains/startssl-sub.class1.server.ca.pem"
  4936. wget "http://www.startssl.com/certs/sub.class2.server.ca.pem" --output-document="/etc/ssl/chains/startssl-sub.class2.server.ca.pem"
  4937. wget "http://www.startssl.com/certs/sub.class3.server.ca.pem" --output-document="/etc/ssl/chains/startssl-sub.class3.server.ca.pem"
  4938. ln -s "/etc/ssl/roots/startssl-root.ca" "/etc/ssl/roots/$HOSTNAME-root.ca"
  4939. ln -s "/etc/ssl/chains/startssl-sub.class1.server.ca.pem" "/etc/ssl/chains/$HOSTNAME.ca"
  4940. cp "/etc/ssl/certs/$HOSTNAME.crt" "/etc/ssl/certs/$HOSTNAME.crt+chain+root"
  4941. test -e "/etc/ssl/chains/$HOSTNAME.ca" && cat "/etc/ssl/chains/$HOSTNAME.ca" >> "/etc/ssl/certs/$HOSTNAME.crt+chain+root"
  4942. test -e "/etc/ssl/roots/$HOSTNAME-root.ca" && cat "/etc/ssl/roots/$HOSTNAME-root.ca" >> "/etc/ssl/certs/$HOSTNAME.crt+chain+root"
  4943. #+END_SRC
  4944. To avoid any possibility of the certificates being accidentally overwritten by self-signed ones at a later date you can create backups.
  4945. #+BEGIN_SRC: bash
  4946. mkdir /etc/ssl/backups
  4947. mkdir /etc/ssl/backups/certs
  4948. mkdir /etc/ssl/backups/private
  4949. cp /etc/ssl/certs/$HOSTNAME* /etc/ssl/backups/certs/
  4950. cp /etc/ssl/private/$HOSTNAME* /etc/ssl/backups/private/
  4951. chmod -R 400 /etc/ssl/backups/certs/*
  4952. chmod -R 400 /etc/ssl/backups/private/*
  4953. #+END_SRC
  4954. Remove the certificate password, so if the server is rebooted then it won't wait indefinitely for a non-existant keyboard user to type in a password.
  4955. #+BEGIN_SRC: bash
  4956. openssl rsa -in /etc/ssl/private/$HOSTNAME.key -out /etc/ssl/private/$HOSTNAME.new.key
  4957. cp /etc/ssl/private/$HOSTNAME.new.key /etc/ssl/private/$HOSTNAME.key
  4958. shred -zu /etc/ssl/private/$HOSTNAME.new.key
  4959. #+END_SRC
  4960. Edit your Apache configuration file.
  4961. #+BEGIN_SRC: bash
  4962. editor /etc/apache2/sites-available/$HOSTNAME
  4963. #+END_SRC
  4964. Add the following to the section which starts with *<VirtualHost *:443>*
  4965. #+BEGIN_SRC: bash
  4966. SSLCertificateChainFile /etc/ssl/chains/startssl-sub.class1.server.ca.pem
  4967. #+END_SRC
  4968. Save and exit, then restart apache.
  4969. #+BEGIN_SRC: bash
  4970. service apache2 restart
  4971. #+END_SRC
  4972. Now visit your web site at https://mydomainname.com and you should notice that there is no certificate warning displayed. You will now be able to install systems which don't allow the use of self-signed certificates, such as [[https://redmatrix.me/&JS=1][Red Matrix]].
  4973. * Deprecated
  4974. The following items have been deprecated until such time as a successful installation is achieved.
  4975. ** Install a VoIP server
  4976. #+BEGIN_VERSE
  4977. /Our core principles, whether in software or sovereignty, have always been about freedom and dignity, for all people, on an equal basis/
  4978. -- David Sugar, GNU Telephony
  4979. #+END_VERSE
  4980. *** The server
  4981. 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.
  4982. Edit your package sources:
  4983. #+BEGIN_SRC: bash
  4984. editor /etc/apt/sources.list
  4985. #+END_SRC
  4986. Append the following line:
  4987. #+BEGIN_SRC: bash
  4988. deb http://dev.gnutelephony.org/archive/ wheezy/
  4989. #+END_SRC
  4990. Save and exit.
  4991. 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
  4992. #+BEGIN_SRC: bash
  4993. apt-get install gnutelephony-keyring
  4994. #+END_SRC
  4995. After that it will be happy to accept it as a signed repository. The verification keys can also be directly fetched with
  4996. #+BEGIN_SRC: bash
  4997. cd /tmp
  4998. wget http://dev.gnutelephony.org/archive/wheezy/public.key
  4999. #+END_SRC
  5000. and manually added instead with
  5001. #+BEGIN_SRC: bash
  5002. apt-key add public.key
  5003. #+END_SRC
  5004. To make sure you have all dependencies, do
  5005. #+BEGIN_SRC: bash
  5006. apt-get update;apt-get dist-upgrade
  5007. #+END_SRC
  5008. Before we install anything, let's inspect what is available to us by using
  5009. #+BEGIN_SRC: bash
  5010. dpkg -l sipwitch
  5011. #+END_SRC
  5012. To see the main application. The columns will indicate if the package is installed, which version and a description of the package. Then do
  5013. #+BEGIN_SRC: bash
  5014. dpkg -l sipwitch-*
  5015. #+END_SRC
  5016. 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.
  5017. To install only the main application, do
  5018. #+BEGIN_SRC: bash
  5019. apt-get install sipwitch
  5020. #+END_SRC
  5021. and to install all supporting plugins:
  5022. #+BEGIN_SRC: bash
  5023. apt-get install sipwitch-plugin-scripting sipwitch-plugin-subscriber sipwitch-plugin-forward sipwitch-plugin-zeroconf
  5024. #+END_SRC
  5025. Add your user into the sipwitch group
  5026. #+BEGIN_SRC: bash
  5027. groupadd sipwitch
  5028. groupadd sipusers
  5029. usermod -aG sipwitch myusername
  5030. usermod -aG sipusers myusername
  5031. #+END_SRC
  5032. Then edit the configuration
  5033. #+BEGIN_SRC: bash
  5034. editor /etc/sipwitch.conf
  5035. #+END_SRC
  5036. Change the *mapped* value from 200 to 20, since we don't want to be serving huge numbers of calls.
  5037. 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.
  5038. Do not set the *realm* value, as doing so seems to prevent the server from working.
  5039. Save and exit.
  5040. Create a digest string for your username:
  5041. #+BEGIN_SRC: bash
  5042. sipwitch digest myusername
  5043. #+END_SRC
  5044. Make a note of the resulting string because you're going to use it in the users file you'll now create.
  5045. #+BEGIN_SRC: bash
  5046. export HOSTNAME=mydomainname.com
  5047. touch /etc/sipwitch.d/$HOSTNAME.xml
  5048. chmod 600 /etc/sipwitch.d/$HOSTNAME.xml
  5049. editor /etc/sipwitch.d/$HOSTNAME.xml
  5050. #+END_SRC
  5051. It should look something like the following:
  5052. #+BEGIN_SRC: bash
  5053. <provision>
  5054. <user id="myusername">
  5055. <digest>yourdigeststring</digest>
  5056. <extension>201</extension>
  5057. <display>Your full name</display>
  5058. </user>
  5059. </provision>
  5060. #+END_SRC
  5061. Save and exit. Now edit the configuration.
  5062. #+BEGIN_SRC: bash
  5063. editor /etc/default/sipwitch
  5064. #+END_SRC
  5065. Change "desktop" to "server", then save and exit.
  5066. Update the IP settings:
  5067. #+BEGIN_SRC: bash
  5068. iptables -A INPUT -p tcp --dport 5060 -j ACCEPT
  5069. iptables -A INPUT -p udp --dport 5060 -j ACCEPT
  5070. iptables -A INPUT -p tcp --dport 5061 -j ACCEPT
  5071. iptables -A INPUT -p udp --dport 5061 -j ACCEPT
  5072. iptables-save
  5073. #+END_SRC
  5074. Test that it's working:
  5075. #+BEGIN_SRC: bash
  5076. pkill -9 sipw
  5077. sipw -x9 -f
  5078. #+END_SRC
  5079. 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.
  5080. #+BEGIN_SRC: bash
  5081. service sipwitch start
  5082. #+END_SRC
  5083. *** Clients
  5084. **** Jitsi
  5085. Download the latst version from https://jitsi.org/index.php/Main/Download
  5086. TODO
  5087. **** Twinkle client
  5088. The client should have a user profile as following:
  5089. The "user name" is the xxx id used in the <user id="xxx"> entry of /etc/sipwitch.conf
  5090. The "domain" is the yyy domain in the main config <stack><domain>yyy entry of /etc/sipwitch.conf
  5091. The SIP Authentication should have:
  5092. realm = realm as set in <registry><realm> of /etc/sipwitch.conf
  5093. authentication name = <user id="xx"> entry, same as "User Name" field.
  5094. password = value of <secret>zzz in <user> entry of /etc/sipwitch.conf
  5095. Under security tab, set "Enable ZRTP/SRTP encryption"
  5096. **** Android
  5097. TODO
  5098. CSipSimple?
  5099. ** Kune
  5100. 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).
  5101. #+BEGIN_SRC: bash
  5102. apt-get install openjdk-6-jdk openjdk-7-jre mysql-server adduser dbconfig-common libjmagick6-jni
  5103. #+END_SRC
  5104. Add the Kune repository:
  5105. #+BEGIN_SRC: bash
  5106. editor /etc/apt/sources.list
  5107. #+END_SRC
  5108. Append the following:
  5109. #+BEGIN_SRC: bash
  5110. deb ftp://ftp.kune.ourproject.org/pub/kune/debian/ stable/
  5111. #+END_SRC
  5112. Save and exit, then install the Kune package.
  5113. #+BEGIN_SRC: bash
  5114. gpg --keyserver pgp.mit.edu --recv-keys 9E358A05
  5115. gpg --armor --export 9E358A05 | apt-key add -
  5116. apt-get update
  5117. apt-get install kune
  5118. #+END_SRC
  5119. You will be asked for the MySql root password and another password to be used with the Kune database.
  5120. Allow the system to start automatically at boot.
  5121. #+BEGIN_SRC: bash
  5122. editor /etc/default/kune
  5123. #+END_SRC
  5124. Set /START=yes/, then save and exit.
  5125. #+BEGIN_SRC: bash
  5126. service kune start
  5127. #+END_SRC
  5128. Now configure Apache.
  5129. #+BEGIN_SRC: bash
  5130. a2enmod expires
  5131. a2enmod proxy
  5132. a2enmod proxy_connect
  5133. a2enmod proxy_http
  5134. #+END_SRC
  5135. Upgrade the database.
  5136. #+BEGIN_SRC: bash
  5137. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.1.0+b5
  5138. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.1.0+b6
  5139. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.2.0+b12
  5140. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.2.0+b23
  5141. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.2.0+b25
  5142. #+END_SRC
  5143. Edit the Apache configuration.
  5144. #+BEGIN_SRC: bash
  5145. editor /etc/apache2/sites-available/$HOSTNAME
  5146. #+END_SRC
  5147. <VirtualHost *:80>
  5148. ServerName YOURSERVERNAME
  5149. ProxyRequests Off
  5150. <Proxy *>
  5151. Order deny,allow
  5152. Allow from all
  5153. </Proxy>
  5154. <Files *.cache.*>
  5155. ExpiresActive On
  5156. ExpiresDefault "modification plus 2 years"
  5157. </Files>
  5158. <Files *.nocache.*>
  5159. ExpiresActive Off
  5160. </Files>
  5161. ProxyPass /kune/ http://localhost:8888/
  5162. ProxyPassReverse /kune/ http://localhost:8888/
  5163. <Location /var/www/mydomainname.com/htdocs/kune/>
  5164. Order allow,deny
  5165. Allow from all
  5166. </Location>
  5167. </VirtualHost>
  5168. Within a browser open https://mydomainname.com:8888
  5169. See documentation in /usr/share/doc/kune/INSTALL.gz
  5170. ** Loomio
  5171. #+BEGIN_SRC: bash
  5172. apt-get install imagemagick libmagickcore-dev postgresql libmagickwand-dev
  5173. #+END_SRC
  5174. psql -d postgres
  5175. postgres=# create role postgres login createdb;
  5176. postgres=# \q
  5177. #+BEGIN_SRC: bash
  5178. cd /srv
  5179. git clone https://github.com/loomio/loomio.git
  5180. cd /srv/loomio
  5181. bundle install
  5182. cp config/database.example.yml config/database.yml
  5183. cp .example-env .env
  5184. bundle exec rake db:create
  5185. bundle exec rake db:schema:load
  5186. bundle exec rake db:schema:load RAILS_ENV=test
  5187. bundle exec rake db:seed
  5188. #+END_SRC
  5189. foreman start
  5190. Edit the Apache configuration for your mediagoblin site.
  5191. #+BEGIN_SRC: bash
  5192. editor /etc/apache2/sites-available/myloomiodomain
  5193. #+END_SRC
  5194. Delete the existing configuration (in Emacs it's CTRL-x h then CTRL-w) and paste the following, replacing /myloomiodomain/ with your mediagoblin domain name and /myusername@mydomainname.com/ with your email address.
  5195. #+BEGIN_SRC: bash
  5196. <VirtualHost *:80>
  5197. ServerAdmin myusername@mydomainname.com
  5198. DocumentRoot /srv/myloomiodomain
  5199. ServerName myloomiodomain
  5200. <Directory />
  5201. Options FollowSymLinks
  5202. AllowOverride None
  5203. </Directory>
  5204. <Directory /srv/myloomiodomain/>
  5205. Options Indexes FollowSymLinks MultiViews
  5206. AllowOverride All
  5207. Order allow,deny
  5208. allow from all
  5209. </Directory>
  5210. LogLevel warn
  5211. ProxyVia On
  5212. ProxyRequests off
  5213. ProxyPreserveHost on
  5214. ProxyPass / http://localhost:3000/
  5215. ErrorLog "/var/log/apache2/error.log"
  5216. CustomLog "/var/log/apache2/access.log" combined
  5217. RewriteEngine On
  5218. RewriteOptions Inherit
  5219. </VirtualHost>
  5220. #+END_SRC
  5221. Save and exit.
  5222. Now in a browser visit http://myloomiodomain and create a user.
  5223. ** Connect Bitmessage to Email
  5224. TODO: how to connect Bitmessage to an email client.
  5225. #+BEGIN_SRC: bash
  5226. cd /tmp
  5227. wget http://freedombone.uk.to/notbit.tar.gz
  5228. #+END_SRC
  5229. Verify it.
  5230. #+BEGIN_SRC: bash
  5231. sha256sum notbit.tar.gz
  5232. 972fdc9cbb8034141282337dcd5e557bce57969ff6bd1d607da89bd93cc7bb68
  5233. #+END_SRC
  5234. Extract and install it.
  5235. #+BEGIN_SRC: bash
  5236. tar -xzvf notbit.tar.gz
  5237. cd notbit
  5238. apt-get install dh-autoreconf
  5239. ./autogen.sh --prefix=/home/myusername
  5240. make
  5241. make install
  5242. #+END_SRC
  5243. ** Add a Convergenge notary
  5244. Convergence is a secure replacement for the Certificate Authority System. Rather than employing a traditionally hard-coded list of immutable and largely untrusted CAs, Convergence allows you to configure a dynamic set of Notaries which use network perspective to validate your communication. For more details see [[http://convergence.io][convergence.io]] or [[http://www.youtube.com/watch?v=Z7Wl2FW2TcA][this talk which explains the concepts]].
  5245. *** Installation
  5246. #+BEGIN_SRC: bash
  5247. apt-get install python python-twisted-web python-twisted-names python-m2crypto python-openssl
  5248. cd /tmp
  5249. git clone https://github.com/fuzzgun/convergence
  5250. cd convergence/server
  5251. python ./setup.py install
  5252. #+END_SRC
  5253. Generate a key pair:
  5254. #+BEGIN_SRC: bash
  5255. convergence gencert
  5256. #+END_SRC
  5257. When asked for a challenge password just hit *Enter* a couple of times. Then move the key pair to the appropriate directories as follows.
  5258. #+BEGIN_SRC: bash
  5259. mv mynotary.key /etc/ssl/private
  5260. chmod 400 /etc/ssl/private/mynotary.key
  5261. mv mynotary.pem /etc/ssl/certs
  5262. #+END_SRC
  5263. Now create the database:
  5264. #+BEGIN_SRC: bash
  5265. rm /var/lib/convergence/convergence.db
  5266. convergence createdb
  5267. #+END_SRC
  5268. Create an initialisation script:
  5269. #+BEGIN_SRC: bash
  5270. editor /etc/init.d/convergence
  5271. #+END_SRC
  5272. Add the following:
  5273. #+BEGIN_SRC: bash
  5274. #+END_SRC
  5275. Save and exit.
  5276. #+BEGIN_SRC: bash
  5277. adduser converg
  5278. #+END_SRC
  5279. The details for the user don't especially matter, but give them a long random password.
  5280. #+BEGIN_SRC: bash
  5281. chown -R converg:converg /home/converg
  5282. chmod +x /etc/init.d/convergence
  5283. update-rc.d convergence defaults
  5284. service convergence start
  5285. #+END_SRC
  5286. Generate a notary bundle:
  5287. #+BEGIN_SRC: bash
  5288. convergence bundle
  5289. #+END_SRC
  5290. Enter your name, nickname, handle or whatever.
  5291. For the bundle location enter https://mydomainname.com/convergence.notary
  5292. For the Hostname enter your domain name
  5293. For SSL port enter *8433* and for HTTP port nter *8432*
  5294. For the pem file enter */etc/ssl/certs/mynotary.pem*
  5295. #+BEGIN_SRC: bash
  5296. export HOSTNAME=mydomainname.com
  5297. mv mynotarybundle.notary /var/www/$HOSTNAME/htdocs/convergence.notary
  5298. chown www-data:www-data /var/www/$HOSTNAME/htdocs/convergence.notary
  5299. #+END_SRC
  5300. Now open ports 8432 and 8433 on your internet router or firewall and direct it to the BBB.
  5301. *** Using Convergence
  5302. On a computer which is not the BBB (your laptop, etc):
  5303. Install the browser plugin by navigating to https://addons.mozilla.org/en-us/firefox/addon/convergence-extra/
  5304. After installation restart your browser.
  5305. You will notice that an icon appears in the top right corner of the browser, which resembles a lock and two plus signs. Click on the down arrow to the right of it and select *options*.
  5306. ** Gitlab
  5307. Install some dependencies:
  5308. #+BEGIN_SRC: bash
  5309. apt-get update -y
  5310. apt-get upgrade -y
  5311. apt-get install sudo -y
  5312. apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate git-core
  5313. #+END_SRC
  5314. Install bundler
  5315. #+BEGIN_SRC: bash
  5316. gem install bundler --no-ri --no-rdoc
  5317. #+END_SRC
  5318. Create a user for running Gitlab.
  5319. #+BEGIN_SRC: bash
  5320. adduser --disabled-login --gecos 'GitLab' git
  5321. #+END_SRC
  5322. Install mysql (it may already be installed).
  5323. #+BEGIN_SRC: bash
  5324. apt-get install -y mysql-server mysql-client libmysqlclient-dev
  5325. mysql_secure_installation
  5326. mysql -u root -p
  5327. #+END_SRC
  5328. Enter the following commands, substituting /gitlabpassword/ with a password to be used for the Gitlab installation.
  5329. #+BEGIN_SRC: bash
  5330. CREATE USER 'git'@'localhost' IDENTIFIED BY 'gitlabpassword';
  5331. SET storage_engine=INNODB;
  5332. CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
  5333. GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'git'@'localhost';
  5334. quit
  5335. #+END_SRC
  5336. Obtain the code and install it.
  5337. #+BEGIN_SRC: bash
  5338. cd /home/git
  5339. sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-8-stable gitlab
  5340. cd /home/git/gitlab
  5341. sudo -u git -H cp /home/git/gitlab/config/gitlab.yml.example /home/git/gitlab/config/gitlab.yml
  5342. sudo -u git -H editor /home/git/gitlab/config/gitlab.yml
  5343. #+END_SRC
  5344. Set /host/ to your gitlab domain name, /port/ to 443 and /https/ to true, then save and exit.
  5345. #+BEGIN_SRC: bash
  5346. chown -R git /home/git/gitlab/log/
  5347. chown -R git /home/git/gitlab/tmp/
  5348. chmod -R u+rwX /home/git/gitlab/log/
  5349. chmod -R u+rwX /home/git/gitlab/tmp/
  5350. sudo -u git -H mkdir /home/git/gitlab-satellites
  5351. chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites
  5352. chmod -R u+rwX /home/git/gitlab/tmp/pids/
  5353. chmod -R u+rwX /home/git/gitlab/tmp/sockets/
  5354. chmod -R u+rwX /home/git/gitlab/public/uploads
  5355. sudo -u git -H cp /home/git/gitlab/config/unicorn.rb.example /home/git/gitlab/config/unicorn.rb
  5356. #sudo -u git -H editor /home/git/gitlab/config/unicorn.rb
  5357. sudo -u git -H cp /home/git/gitlab/config/initializers/rack_attack.rb.example /home/git/gitlab/config/initializers/rack_attack.rb
  5358. sudo -u git -H git config --global user.name "GitLab"
  5359. sudo -u git -H git config --global user.email "gitlab@localhost"
  5360. sudo -u git -H git config --global core.autocrlf input
  5361. sudo -u git cp /home/git/gitlab/config/database.yml.mysql /home/git/gitlab/config/database.yml
  5362. sudo -u git -H chmod o-rwx /home/git/gitlab/config/database.yml
  5363. sudo -u git -H bundle install --deployment --without development test postgres aws
  5364. #+END_SRC
  5365. Fails here with:
  5366. /Could not find libv8-3.16.14.3 in any of the sources/
  5367. /Run `bundle install` to install missing gems./
  5368. #+BEGIN_SRC: bash
  5369. sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
  5370. sudo -u git -H bundle exec rake gitlab:shell:install[v1.9.3] REDIS_URL=redis://localhost:6379
  5371. sudo -u git -H editor /home/git/gitlab-shell/config.yml
  5372. cp lib/support/init.d/gitlab /etc/init.d/gitlab
  5373. update-rc.d gitlab defaults 21
  5374. cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
  5375. sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
  5376. sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
  5377. service gitlab start
  5378. #+END_SRC
  5379. Set up the Apache configuration.
  5380. #+BEGIN_SRC: bash
  5381. cp lib/support/apache/gitlab /etc/apache2/sites-available/mygitlabdomain
  5382. editor /etc/apache2/sites-available/mygitlabdomain
  5383. #+END_SRC
  5384. Set your domain name and email accordingly.
  5385. #+BEGIN_SRC: bash
  5386. a2ensite mygitlabdomain
  5387. #+END_SRC
  5388. * Related projects
  5389. * [[https://freedomboxfoundation.org/][Freedombox]]
  5390. * [[https://arkos.io/][ArkOS]]
  5391. * [[https://github.com/JoshData/mailinabox][Mail-in-a-Box]]