beaglebone.txt 224KB

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