beaglebone.txt 218KB

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