beaglebone.txt 199KB

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