beaglebone.txt 200KB

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