beaglebone.txt 249KB

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