beaglebone.txt 148KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645
  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. #+CAPTION: BeagleBone Black
  12. #+ATTR_HTML: :alt BeagleBone Black image :align center
  13. [[[[./images/freedombone.jpg]]]]
  14. #+BEGIN_CENTER
  15. Copyright (C) 2014 Bob Mottram
  16. 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.
  17. 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]].
  18. #+END_CENTER
  19. * Introduction
  20. #+BEGIN_VERSE
  21. /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./
  22. -- Edward J. Snowden
  23. #+END_VERSE
  24. ** What is FreedomBone?
  25. 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.
  26. 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.
  27. ** Do I need any prior knowledge?
  28. 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.
  29. ** Why should I do this?
  30. 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).
  31. 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.
  32. 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.
  33. ** After it's installed will it need a lot of maintenance?
  34. 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.
  35. ** Is it secure?
  36. 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.
  37. 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.
  38. ** Will running a server all the time affect my electricity bill?
  39. Hardly at all. The BeagleBone Black consumes very little power - less than 5W. It would even be potentially possible to run it from a solar panel.
  40. ** Can I use a Raspberry Pi or Cubieboard instead?
  41. These instructions are not highly specific to the Beaglebone Black and so will likely also work on other single board computers (SBCs) such as the [[https://en.wikipedia.org/wiki/Raspberry_pi][Raspberry Pi]] or [[https://en.wikipedia.org/wiki/Cubieboard][Cubieboard]]. The original Raspberry Pi only had 256MB of RAM and so the performance of some services may be more limited. The Beaglebone Black was chosen mainly because of its low cost, relatively good CPU performance for the price (by the standards of 2013) and also low electricity consumption. The Cubieboard is also another good alternative, with the A20 version having similar specifications but twice as much RAM as the BeagleBone Black.
  42. ** Why should I trust the packages or source code downloaded from this site?
  43. If you're particularly security conscious then you shouldn't. Binary or source packages have only been included here for convenience and to avoid confusion. "/Go and find a Debian installation for the BeagleBone Black somewhere on the web/" is too vague an instruction for my liking, and I've attempted to keep things as concise and unambiguous as possible - particularly with an average or new Linux user in mind.
  44. However, for maximum security for those software systems which are not already packaged within the Debian repositories then seek out the original sources and verify the hashes independently.
  45. It's worth adopting an attitude of "/trust but verify/". Don't let fear of mass surveillance and [[https://www.techdirt.com/articles/20140207/08354426130/gchq-has-entire-program-dirty-tricks-including-honeypots-using-journalists-deleting-online-accounts.shtml]["dirty tricks"]] paralyse you into trusting nothing and consequently doing nothing. Doing nothing means they win.
  46. * Inventory
  47. #+BEGIN_VERSE
  48. /You can’t help someone just by making a wish to do so, you have to take action./
  49. -- Dalai Lama
  50. #+END_VERSE
  51. These instructions assume that you have the following ingredients.
  52. ** A BeagleBone Black (BBB)
  53. 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.
  54. ** An internet connection
  55. 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.
  56. ** microSD card
  57. 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.
  58. 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.
  59. ** 5V/1A power supply
  60. 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.
  61. ** An ethernet patch cable
  62. Just an ordinary cat5 or cat6 cable that you can get from most electrical/computer stores.
  63. * Installing Debian onto the microSD card
  64. 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.
  65. Download the image.
  66. #+BEGIN_SRC: bash
  67. cd ~/
  68. wget http://freedombone.uk.to/debian-7.2-console-armhf-2013-11-15.tar.xz
  69. #+END_SRC
  70. Verify it.
  71. #+BEGIN_SRC: bash
  72. sha256sum debian-7.2-console-armhf-2013-11-15.tar.xz
  73. 262ea96d6bff530ad545e001eb2aa50b26a999c02f0c0e2e5f8536edf21c973a debian-7.2-console-armhf-2013-11-15.tar.xz
  74. #+END_SRC
  75. Uncompress it.
  76. #+BEGIN_SRC: bash
  77. tar xJf debian-7.2-console-armhf-2013-11-15.tar.xz
  78. cd debian-7.2-console-armhf-2013-11-15
  79. #+END_SRC
  80. Create the disk image, where sdX is the name of the flash drive (probably it will be sdb or sdc).
  81. #+BEGIN_SRC: bash
  82. sudo apt-get install u-boot-tools
  83. sudo ./setup_sdcard.sh --mmc /dev/sdX --uboot bone --swap-file 1024
  84. #+END_SRC
  85. Once completed then safely remove the microSD card via your file manager (usually right click and "safely remove" or "eject").
  86. * Setup
  87. #+BEGIN_VERSE
  88. /Build the tools for a future you would want to live in/
  89. -- Kurt Opsahl
  90. #+END_VERSE
  91. ** Things to be aware of
  92. *** A note on ssh
  93. 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:
  94. #+BEGIN_SRC: bash
  95. ssh-keygen -R <IP address>
  96. #+END_SRC
  97. *** Passwords
  98. 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.
  99. *** HTTPS
  100. 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..
  101. 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.
  102. ** Initial
  103. Plug the microSD card into the BBB and Connect the USB cable to your laptop/desktop, then login via ssh.
  104. #+BEGIN_SRC: bash
  105. ssh debian@192.168.7.2
  106. #+END_SRC
  107. The default password is /temppwd/
  108. Then log in as root:
  109. #+BEGIN_SRC: bash
  110. su
  111. #+END_SRC
  112. The default password is /root/
  113. The first thing to do is to change the passwords from their defaults.
  114. #+BEGIN_SRC: bash
  115. passwd
  116. #+END_SRC
  117. 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.
  118. #+BEGIN_SRC: bash
  119. nano /etc/network/interfaces
  120. #+END_SRC
  121. The resulting interfaces file should look like this:
  122. #+BEGIN_SRC: bash
  123. # This file describes the network interfaces available on your system
  124. # and how to activate them. For more information, see interfaces(5).
  125. # The loopback network interface
  126. auto lo
  127. iface lo inet loopback
  128. # The primary network interface
  129. allow-hotplug eth0
  130. iface eth0 inet static
  131. address 192.168.1.60
  132. netmask 255.255.255.0
  133. gateway 192.168.1.254
  134. dns-nameservers 213.73.91.35 85.214.20.141
  135. # Example to keep MAC address between reboots
  136. #hwaddress ether DA:AD:CE:EF:CA:FE
  137. # WiFi Example
  138. #auto wlan0
  139. #iface wlan0 inet dhcp
  140. # wpa-ssid "essid"
  141. # wpa-psk "password"
  142. # Ethernet/RNDIS gadget (g_ether)
  143. # ... or on host side, usbnet and random hwaddr
  144. # Note on some boards, usb0 is automaticly setup with an init script
  145. # in that case, to completely disable remove file [run_boot-scripts] from the boot partition
  146. #iface usb0 inet static
  147. # address 192.168.7.2
  148. # netmask 255.255.255.0
  149. # network 192.168.7.0
  150. # gateway 192.168.7.1
  151. #+END_SRC
  152. CTRL-O followed by ENTER to save, then CTRL-X to exit.
  153. 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.
  154. "gateway 192.168.1.254" should be the IP address of the router.
  155. Note that setting the DNS servers with dns-nameservers is important because some home routers do not allow you to change the DNS settings.
  156. Edit resolv.conf.
  157. #+BEGIN_SRC: bash
  158. nano /etc/resolv.conf
  159. #+END_SRC
  160. It should look something like the following:
  161. #+BEGIN_SRC: bash
  162. domain localdomain
  163. search localdomain
  164. nameserver 213.73.91.35
  165. nameserver 85.214.20.141
  166. #+END_SRC
  167. CTRL-O followed by ENTER to save, then CTRL-X to exit.
  168. 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.
  169. 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".
  170. ** Add a user
  171. Ssh back in to the BBB and login as root. In this example the BBB's IP address is 192.168.1.60.
  172. #+BEGIN_SRC: bash
  173. ssh-keygen -f "/home/myusername/.ssh/known_hosts" -R 192.168.1.60
  174. ssh debian@192.168.1.60
  175. su
  176. #+END_SRC
  177. 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.
  178. #+BEGIN_SRC: bash
  179. adduser myusername
  180. #+END_SRC
  181. 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.
  182. Remove the default debian user.
  183. #+BEGIN_SRC: bash
  184. userdel -r debian
  185. #+END_SRC
  186. ** Text editor
  187. For an editor which is less erratic than vi when used within a remote console such as Terminator.
  188. #+BEGIN_SRC: bash
  189. apt-get update
  190. apt-get install emacs
  191. #+END_SRC
  192. Some basic Emacs keys which will be useful to new users are:
  193. | Load a file | CTRL-x CTRL-f |
  194. | Save | CTRL-x CTRL-s |
  195. | Exit | CTRL-x CTRL-c |
  196. ** Create a swap file
  197. 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:
  198. #+BEGIN_SRC: bash
  199. mkdir -p /var/cache/swap/
  200. dd if=/dev/zero of=/var/cache/swap/swapfile bs=1M count=1024
  201. chmod 600 /var/cache/swap/swapfile
  202. mkswap /var/cache/swap/swapfile
  203. swapon /var/cache/swap/swapfile
  204. #+END_SRC
  205. To tell the OS to load this swapfile on each start up.
  206. #+BEGIN_SRC: bash
  207. emacs /etc/fstab
  208. #+END_SRC
  209. Append the following line:
  210. #+BEGIN_SRC: bash
  211. /var/cache/swap/swapfile none swap sw 0 0
  212. #+END_SRC
  213. Then save and exit.
  214. 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.
  215. ** Enable backports
  216. To enable some newer packages add backports to the repositories.
  217. #+BEGIN_SRC: bash
  218. echo "deb http://ftp.us.debian.org/debian wheezy-backports main" >> /etc/apt/sources.list
  219. apt-get update
  220. apt-get dist-upgrade
  221. #+END_SRC
  222. ** Random number generation
  223. #+BEGIN_VERSE
  224. /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./
  225. -- Bruce Schneier, on the 2013 leaked NSA documents
  226. #+END_VERSE
  227. 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.
  228. To improve entropy generation there are two options. One is to install a kernel module which enables the hardware crypto available on the BBB, but that's a bit complicated and might have some stability implications. The other option is to install [[http://www.issihosts.com/haveged/][havegd]]. While not as good as a true hardware random number generator, havegd is better than the default pseudo-random number generation within the Linux kernel. To install it:
  229. #+BEGIN_SRC: bash
  230. apt-get install haveged
  231. #+END_SRC
  232. 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.
  233. ** Alter ssh configuration
  234. Altering the ssh configuration will make it a little more secure than the standard Debian settings.
  235. #+BEGIN_SRC: bash
  236. emacs /etc/ssh/sshd_config
  237. #+END_SRC
  238. Check the following values:
  239. #+BEGIN_SRC: bash
  240. PermitRootLogin no
  241. X11Forwarding no
  242. ServerKeyBits 4096
  243. Protocol 2
  244. PermitEmptyPasswords no
  245. StrictModes yes
  246. #+END_SRC
  247. Append the following:
  248. #+BEGIN_SRC: bash
  249. Ciphers aes256-ctr,aes192-ctr,aes128-ctr
  250. MACs hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
  251. KexAlgorithms diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1
  252. #+END_SRC
  253. CTRL-X CTRL-S to save, then CTRL-X CTRL-C to exit.
  254. #+BEGIN_SRC: bash
  255. service ssh restart
  256. #+END_SRC
  257. To test the new settings log out by typing "exit" a couple of times, then log back in again with:
  258. #+BEGIN_SRC: bash
  259. ssh -vvv myusername@192.168.1.60
  260. #+END_SRC
  261. and check that some number of bits are set within a 4096 bit sized key:
  262. #+BEGIN_SRC: bash
  263. debug2: bits set: */4096
  264. #+END_SRC
  265. ** Getting onto the web
  266. 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.
  267. Select "/dynamic DNS/" then click "/quick cron example/"
  268. An example would look like:
  269. #+BEGIN_SRC: bash
  270. 4,9,14,19,24,29,34,39,44,49,54,59 * * * * root sleep 29 ; wget -O - http://free\ dns.afraid.org/dynamic/update.php?ABCKDNRCLFHENSLKNFEGSBFLFF== >> /\ tmp/freedns_mysubdomain_us_to.log 2>&1 &
  271. #+END_SRC
  272. Edit */etc/crontab* and append that to the end of the file.
  273. 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.
  274. The freeDNS subdomain which you just created will hereafter just be refered to as "/your domain name/".
  275. ** Set the host name
  276. #+BEGIN_SRC: bash
  277. emacs /etc/hostname
  278. #+END_SRC
  279. CTRL-x CTRL-s to save, then CTRL-x CTRL-c to exit.
  280. Also issue the command, replacing /mydomainname.com/ with your domain name.
  281. #+BEGIN_SRC: bash
  282. hostname mydomainname.com
  283. #+END_SRC
  284. You may also need to assign the same hostname separately via your router's web interface.
  285. #+BEGIN_SRC: bash
  286. emacs /etc/hosts
  287. #+END_SRC
  288. Append the following, replacing /mydomainname.com/ with your domain name.
  289. #+BEGIN_SRC: bash
  290. 127.0.1.1 mydomainname.com
  291. #+END_SRC
  292. If you then run the command:
  293. #+BEGIN_SRC: bash
  294. hostname -f
  295. #+END_SRC
  296. it should return your domain name.
  297. ** Install NTP
  298. To synchronise time.
  299. #+BEGIN_SRC: bash
  300. apt-get install ntp
  301. #+END_SRC
  302. ** Install fail2ban
  303. #+BEGIN_SRC: bash
  304. apt-get install fail2ban
  305. #+END_SRC
  306. ** Set up a firewall
  307. #+BEGIN_VERSE
  308. /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/
  309. -- NBC News article: /War on Anonymous: British Spies Attacked Hackers, Snowden Docs Show/
  310. #+END_VERSE
  311. 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.
  312. #+BEGIN_SRC: bash
  313. apt-get install portsentry
  314. emacs /etc/portsentry/portsentry.conf
  315. #+END_SRC
  316. Uncomment the entry for *iptables support for Linux*
  317. Set the following properties:
  318. #+BEGIN_SRC: bash
  319. 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"
  320. 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"
  321. ADVANCED_EXCLUDE_TCP="113,139,70,80,443,143,6670,993,5060,5061,25,465,22,5222,5223,5269,5280,5281,8444"
  322. ADVANCED_EXCLUDE_UDP="520,138,137,67,70,80,443,143,6670,993, 5060,5061,25,465,22,5222,5223,5269,5280,5281,8444"
  323. SCAN_TRIGGER="2"
  324. BLOCK_UDP="2"
  325. BLOCK_TCP="2"
  326. #+END_SRC
  327. Save and exit.
  328. #+BEGIN_SRC: bash
  329. service portsentry restart
  330. emacs /tmp/firewall.sh
  331. #+END_SRC
  332. Enter the following:
  333. #+BEGIN_SRC: bash
  334. #!/bin/bash
  335. # Enable syn cookies
  336. echo 1 > /proc/sys/net/ipv4/tcp_syncookies
  337. # Other settings
  338. echo 1 > /proc/sys/net/ipv4/tcp_keepalive_probes
  339. echo 2 > /proc/sys/net/ipv4/tcp_synack_retries
  340. echo 1 > /proc/sys/net/ipv4/tcp_syn_retries
  341. # First of all delete any existing rules.
  342. # This means you're back to a known state:
  343. iptables -P INPUT ACCEPT
  344. iptables -F
  345. iptables -X
  346. # Drop access to unused ports
  347. iptables -A INPUT -p tcp --destination-port 1 -j DROP
  348. iptables -A INPUT -p tcp --destination-port 7 -j DROP
  349. iptables -A INPUT -p tcp --destination-port 109:111 -j DROP
  350. iptables -A INPUT -p tcp --destination-port 995 -j DROP
  351. iptables -A INPUT -p tcp --destination-port 139 -j DROP
  352. iptables -A INPUT -p tcp --destination-port 6000:6001 -j DROP
  353. iptables -A INPUT -p tcp --destination-port 9 -j DROP
  354. iptables -A INPUT -p tcp --destination-port 79 -j DROP
  355. iptables -A INPUT -p tcp --destination-port 515 -j DROP
  356. iptables -A INPUT -p tcp --destination-port 4001 -j DROP
  357. iptables -A INPUT -p tcp --destination-port 1524 -j DROP
  358. iptables -A INPUT -p tcp --destination-port 1080 -j DROP
  359. iptables -A INPUT -p tcp --destination-port 512:514 -j DROP
  360. iptables -A INPUT -p tcp --destination-port 31337 -j DROP
  361. iptables -A INPUT -p tcp --destination-port 2000:2001 -j DROP
  362. iptables -A INPUT -p tcp --destination-port 12345 -j DROP
  363. iptables -A INPUT -p tcp --destination-port 32771:32774 -j DROP
  364. iptables -A INPUT -p tcp --destination-port 4000 -j DROP
  365. iptables -A INPUT -p tcp --destination-port 119 -j DROP
  366. iptables -A INPUT -p tcp --destination-port 137 -j DROP
  367. iptables -A INPUT -p udp --destination-port 1 -j DROP
  368. iptables -A INPUT -p udp --destination-port 7 -j DROP
  369. iptables -A INPUT -p udp --destination-port 109:111 -j DROP
  370. iptables -A INPUT -p udp --destination-port 995 -j DROP
  371. iptables -A INPUT -p udp --destination-port 139 -j DROP
  372. iptables -A INPUT -p udp --destination-port 6000:6001 -j DROP
  373. iptables -A INPUT -p udp --destination-port 9 -j DROP
  374. iptables -A INPUT -p udp --destination-port 79 -j DROP
  375. iptables -A INPUT -p udp --destination-port 515 -j DROP
  376. iptables -A INPUT -p udp --destination-port 4001 -j DROP
  377. iptables -A INPUT -p udp --destination-port 1524 -j DROP
  378. iptables -A INPUT -p udp --destination-port 1080 -j DROP
  379. iptables -A INPUT -p udp --destination-port 512:514 -j DROP
  380. iptables -A INPUT -p udp --destination-port 31337 -j DROP
  381. iptables -A INPUT -p udp --destination-port 2000:2001 -j DROP
  382. iptables -A INPUT -p udp --destination-port 12345 -j DROP
  383. iptables -A INPUT -p udp --destination-port 32771:32774 -j DROP
  384. iptables -A INPUT -p udp --destination-port 4000 -j DROP
  385. iptables -A INPUT -p udp --destination-port 119 -j DROP
  386. iptables -A INPUT -p udp --destination-port 137 -j DROP
  387. # Make sure NEW incoming tcp connections are SYN packets
  388. iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
  389. # Drop packets with incoming fragments
  390. iptables -A INPUT -f -j DROP
  391. # Incoming malformed XMAS packets drop them
  392. iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
  393. iptables -A INPUT -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP
  394. iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
  395. # Incoming malformed NULL packets:
  396. iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
  397. # Drop UDP to used ports
  398. iptables -A INPUT -p udp --match multiport --dports 70,80,443,143,6670,993,5060,5061,25 -j DROP
  399. iptables -A INPUT -p udp --match multiport --dports 465,22,5222,5223,5269,5280,5281,8444 -j DROP
  400. # Limit ssh logins
  401. iptables -A INPUT -p tcp --dport 22 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  402. # Limit web connections
  403. iptables -A INPUT -p tcp --dport 80 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  404. iptables -A INPUT -p tcp --dport 443 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  405. # Limit number of XMPP connections
  406. iptables -A INPUT -p tcp --match multiport --dports 5222:5223,5269,5280:5281 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  407. # Limit IRC connections
  408. iptables -A INPUT -p tcp --dport 6666:6670 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  409. # Limit gopher connections
  410. iptables -A INPUT -p tcp --dport 70 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  411. # Limit IMAP connections
  412. iptables -A INPUT -p tcp --dport 143 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  413. iptables -A INPUT -p tcp --dport 993 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  414. # Limit SIP connections
  415. iptables -A INPUT -p tcp --dport 5060:5061 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  416. # Limit SMTP/SMTPS connections
  417. iptables -A INPUT -p tcp --dport 25 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  418. iptables -A INPUT -p tcp --dport 465 -m limit --limit 3/minute --limit-burst 1 -j ACCEPT
  419. # Limit Bitmessage connections
  420. iptables -A INPUT -p tcp --dport 8444 -m limit --limit 10/minute --limit-burst 1 -j ACCEPT
  421. # Limit the number of incoming tcp connections
  422. # Interface 0 incoming syn-flood protection
  423. iptables -N syn_flood
  424. iptables -A INPUT -p tcp --syn -j syn_flood
  425. iptables -A syn_flood -m limit --limit 1/s --limit-burst 3 -j RETURN
  426. iptables -A syn_flood -j DROP
  427. # Limiting the incoming icmp ping request:
  428. #iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 1 -j ACCEPT
  429. #iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 1 -j LOG --log-prefix PING-DROP:
  430. iptables -A INPUT -p icmp -j DROP
  431. #iptables -A OUTPUT -p icmp -j ACCEPT
  432. # Save the settings
  433. iptables-save > /etc/firewall.conf
  434. echo '#!/bin/sh' > /etc/network/if-up.d/iptables
  435. echo 'iptables-restore < /etc/firewall.conf' >> /etc/network/if-up.d/iptables
  436. chmod +x /etc/network/if-up.d/iptables
  437. #+END_SRC
  438. Save and exit
  439. #+BEGIN_SRC: bash
  440. chmod +x /tmp/firewall.sh
  441. . /tmp/firewall.sh
  442. rm /tmp/firewall.sh
  443. #+END_SRC
  444. 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.
  445. #+BEGIN_SRC: bash
  446. emacs /etc/sysctl.conf
  447. #+END_SRC
  448. Uncomment or change the following:
  449. #+BEGIN_SRC: bash
  450. net.ipv4.conf.all.accept_redirects = 0
  451. net.ipv6.conf.all.accept_redirects = 0
  452. net.ipv4.conf.all.send_redirects = 0
  453. net.ipv4.conf.all.accept_source_route = 0
  454. net.ipv6.conf.all.accept_source_route = 0
  455. net.ipv4.conf.default.rp_filter=1
  456. net.ipv4.conf.all.rp_filter=1
  457. #+END_SRC
  458. And append the following:
  459. #+BEGIN_SRC: bash
  460. # ignore pings
  461. net.ipv4.icmp_echo_ignore_all = 1
  462. #+END_SRC
  463. 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:
  464. #+BEGIN_SRC: bash
  465. reboot
  466. #+END_SRC
  467. ** Install Email
  468. #+BEGIN_VERSE
  469. /If you knew what I know about email, you might not use it/
  470. -- Ladar Levison
  471. #+END_VERSE
  472. 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.
  473. Exim4 seems much easier to install and configure than Postfix.
  474. #+BEGIN_SRC: bash
  475. aptitude install exim4 sasl2-bin swaks libnet-ssleay-perl procmail
  476. #+END_SRC
  477. You will be prompted to remove postfix. Say yes and yes again.
  478. #+BEGIN_SRC: bash
  479. dpkg-reconfigure exim4-config
  480. #+END_SRC
  481. Settings as follows:
  482. #+BEGIN_SRC: bash
  483. internet site
  484. System mail name: mydomainname.com
  485. IP addresses to listen on: blank
  486. Destinations: mydomainname.com
  487. Domains to relay mail: blank
  488. Smarthost Relay: 192.168.1.0/60 (the range of addresses on your LAN)
  489. Dial on demand = no
  490. Maildir format in home directory
  491. Split configuration = no
  492. Root and postmaster: root email
  493. #+END_SRC
  494. To test the installation:
  495. #+BEGIN_SRC: bash
  496. telnet 192.168.1.60 25
  497. ehlo xxx
  498. quit
  499. #+END_SRC
  500. #+BEGIN_SRC: bash
  501. emacs /etc/default/saslauthd
  502. #+END_SRC
  503. set START=yes then save and exit.
  504. #+BEGIN_SRC: bash
  505. /etc/init.d/saslauthd start
  506. emacs exim-gencert
  507. #+END_SRC
  508. #+BEGIN_SRC: bash
  509. #!/bin/sh -e
  510. if [ -n "$EX4DEBUG" ]; then
  511. echo "now debugging $0 $@"
  512. set -x
  513. fi
  514. DIR=/etc/exim4
  515. CERT=$DIR/exim.crt
  516. KEY=$DIR/exim.key
  517. # This exim binary was built with GnuTLS which does not support dhparams
  518. # from a file. See /usr/share/doc/exim4-base/README.Debian.gz
  519. #DH=$DIR/exim.dhparam
  520. if ! which openssl > /dev/null ;then
  521. echo "$0: openssl is not installed, exiting" 1>&2
  522. exit 1
  523. fi
  524. # valid for ten years
  525. DAYS=3650
  526. if [ "$1" != "--force" ] && [ -f $CERT ] && [ -f $KEY ]; then
  527. echo "[*] $CERT and $KEY exists!"
  528. echo " Use \"$0 --force\" to force generation!"
  529. exit 0
  530. fi
  531. if [ "$1" = "--force" ]; then
  532. shift
  533. fi
  534. #SSLEAY=/tmp/exim.ssleay.$$.cnf
  535. SSLEAY="$(tempfile -m600 -pexi)"
  536. cat > $SSLEAY <<EOM
  537. RANDFILE = $HOME/.rnd
  538. [ req ]
  539. default_bits = 4096
  540. default_keyfile = exim.key
  541. distinguished_name = req_distinguished_name
  542. [ req_distinguished_name ]
  543. countryName = Country Code (2 letters)
  544. countryName_default = GB
  545. countryName_min = 2
  546. countryName_max = 2
  547. stateOrProvinceName = State or Province Name (full name)
  548. localityName = Locality Name (eg, city)
  549. organizationName = Organization Name (eg, company; recommended)
  550. organizationName_max = 64
  551. organizationalUnitName = Organizational Unit Name (eg, section)
  552. organizationalUnitName_max = 64
  553. commonName = Server name (eg. ssl.domain.tld; required!!!)
  554. commonName_max = 64
  555. emailAddress = Email Address
  556. emailAddress_max = 40
  557. EOM
  558. echo "[*] Creating a self signed SSL certificate for Exim!"
  559. echo " This may be sufficient to establish encrypted connections but for"
  560. echo " secure identification you need to buy a real certificate!"
  561. echo " "
  562. echo " Please enter the hostname of your MTA at the Common Name (CN) prompt!"
  563. echo " "
  564. openssl req -config $SSLEAY -x509 -sha256 -newkey rsa:4096 -keyout $KEY -out $CERT -days $DAYS -nodes
  565. #see README.Debian.gz*# openssl dhparam -check -text -5 512 -out $DH
  566. rm -f $SSLEAY
  567. chown root:Debian-exim $KEY $CERT $DH
  568. chmod 640 $KEY $CERT $DH
  569. echo "[*] Done generating self signed certificates for exim!"
  570. echo " Refer to the documentation and example configuration files"
  571. echo " over at /usr/share/doc/exim4-base/ for an idea on how to enable TLS"
  572. echo " support in your mail transfer agent."
  573. #+END_SRC
  574. Save and exit
  575. #+BEGIN_SRC: bash
  576. chmod +x exim-gencert
  577. ./exim-gencert
  578. #+END_SRC
  579. 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.
  580. #+BEGIN_SRC: bash
  581. emacs /etc/exim4/exim4.conf.template
  582. #+END_SRC
  583. Append the following:
  584. #+BEGIN_SRC: bash
  585. login_saslauthd_server:
  586. driver = plaintext
  587. public_name = LOGIN
  588. server_prompts = "Username:: : Password::"
  589. # don't send system passwords over unencrypted connections
  590. server_condition = ${if saslauthd{{$auth1}{$auth2}}{1}{0}}
  591. server_set_id = $auth1
  592. .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
  593. server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
  594. .endif
  595. #+END_SRC
  596. Search for the line *.ifdef MAIN_HARDCODE_PRIMARY_HOSTNAME* and above it insert the line:
  597. #+BEGIN_SRC: bash
  598. MAIN_HARDCODE_PRIMARY_HOSTNAME = mydomainname.com
  599. #+END_SRC
  600. Save and exit.
  601. #+BEGIN_SRC: bash
  602. emacs /etc/exim4/exim4.conf.template
  603. #+END_SRC
  604. Add the line:
  605. #+BEGIN_SRC: bash
  606. MAIN_TLS_ENABLE = true
  607. #+END_SRC
  608. Save and exit.
  609. #+BEGIN_SRC: bash
  610. emacs /etc/default/exim4
  611. change SMTPLISTENEROPTIONS to:
  612. SMTPLISTENEROPTIONS='-oX 465:25 -oP /var/run/exim4/exim.pid'
  613. #+END_SRC
  614. save and exit
  615. #+BEGIN_SRC: bash
  616. emacs /etc/exim4/exim4.conf.template
  617. under the section "main/03_exim4-config_tlsoptions"
  618. Add the following:
  619. tls_on_connect_ports=465
  620. #+END_SRC
  621. save and exit
  622. #+BEGIN_SRC: bash
  623. adduser myusername sasl
  624. addgroup Debian-exim sasl
  625. /etc/init.d/exim4 restart
  626. mkdir -m 700 /etc/skel/Maildir
  627. mkdir -m 700 /etc/skel/Maildir/Sent
  628. mkdir -m 700 /etc/skel/Maildir/Sent/tmp
  629. mkdir -m 700 /etc/skel/Maildir/Sent/cur
  630. mkdir -m 700 /etc/skel/Maildir/Sent/new
  631. mkdir -m 700 /etc/skel/Maildir/.learn-spam
  632. mkdir -m 700 /etc/skel/Maildir/.learn-spam/cur
  633. mkdir -m 700 /etc/skel/Maildir/.learn-spam/new
  634. mkdir -m 700 /etc/skel/Maildir/.learn-spam/tmp
  635. mkdir -m 700 /etc/skel/Maildir/.learn-ham
  636. mkdir -m 700 /etc/skel/Maildir/.learn-ham/cur
  637. mkdir -m 700 /etc/skel/Maildir/.learn-ham/new
  638. mkdir -m 700 /etc/skel/Maildir/.learn-ham/tmp
  639. ln -s /etc/skel/Maildir/.learn-spam /etc/skel/Maildir/spam
  640. ln -s /etc/skel/Maildir/.learn-ham /etc/skel/Maildir/ham
  641. #+END_SRC
  642. If you're starting from scratch and don't already have a /Maildir/ directory in your home directory, then create one as follows:
  643. #+BEGIN_SRC: bash
  644. export MYUSERNAME=myusername
  645. mkdir -m 700 /home/$MYUSERNAME/Maildir
  646. mkdir -m 700 /home/$MYUSERNAME/Maildir/cur
  647. mkdir -m 700 /home/$MYUSERNAME/Maildir/tmp
  648. mkdir -m 700 /home/$MYUSERNAME/Maildir/new
  649. mkdir -m 700 /home/$MYUSERNAME/Maildir/Sent
  650. mkdir -m 700 /home/$MYUSERNAME/Maildir/Sent/cur
  651. mkdir -m 700 /home/$MYUSERNAME/Maildir/Sent/tmp
  652. mkdir -m 700 /home/$MYUSERNAME/Maildir/Sent/new
  653. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-spam
  654. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-spam/cur
  655. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-spam/new
  656. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-spam/tmp
  657. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-ham
  658. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-ham/cur
  659. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-ham/new
  660. mkdir -m 700 /home/$MYUSERNAME/Maildir/.learn-ham/tmp
  661. ln -s /home/$MYUSERNAME/Maildir/.learn-spam /home/$MYUSERNAME/Maildir/spam
  662. ln -s /home/$MYUSERNAME/Maildir/.learn-ham /home/$MYUSERNAME/Maildir/ham
  663. chown -R $MYUSERNAME:$MYUSERNAME /home/$MYUSERNAME/Maildir
  664. #+END_SRC
  665. ** Spam filtering
  666. #+BEGIN_SRC: bash
  667. apt-get install spamassassin exim4-daemon-heavy
  668. emacs /etc/default/spamassassin
  669. #+END_SRC
  670. Set ENABLED=1 then save and exit.
  671. #+BEGIN_SRC: bash
  672. emacs /etc/exim4/exim4.conf.template
  673. #+END_SRC
  674. uncomment or change according to your configuration
  675. #+BEGIN_SRC: bash
  676. # For spam scanning, there is a similar option that defines the interface to
  677. # SpamAssassin. You do not need to set this if you are using the default, which
  678. # is shown in this commented example. As for virus scanning, you must also
  679. # modify the acl_check_data access control list to enable spam scanning.
  680. spamd_address = 127.0.0.1 783
  681. #+END_SRC
  682. add spam header in the /acl_check_data/ section:
  683. #+BEGIN_SRC: bash
  684. ### acl/40_exim4-config_check_data
  685. #################################
  686. # This ACL is used after the contents of a message have been received. This
  687. # is the ACL in which you can test a message's headers or body, and in
  688. # particular, this is where you can invoke external virus or spam scanners.
  689. acl_check_data:
  690. ...
  691. ...
  692. ...
  693. # See the exim docs and the exim wiki for more suitable examples.
  694. #
  695. # warn
  696. # spam = Debian-exim:true
  697. # add_header = X-Spam_score: $spam_score\n\
  698. # X-Spam_score_int: $spam_score_int\n\
  699. # X-Spam_bar: $spam_bar\n\
  700. # X-Spam_report: $spam_report
  701. # put headers in all messages (no matter if spam or not)
  702. warn spam = nobody:true
  703. add_header = X-Spam-Score: $spam_score ($spam_bar)
  704. add_header = X-Spam-Report: $spam_report
  705. # add second subject line with *SPAM* marker when message
  706. # is over threshold
  707. warn spam = nobody
  708. add_header = Subject: ***SPAM (score:$spam_score)*** $h_Subject:
  709. #+END_SRC
  710. Save and exit.
  711. Then restart
  712. #+BEGIN_SRC: bash
  713. exit
  714. emacs ~/.procmailrc
  715. #+END_SRC
  716. The text should look like the following.
  717. #+BEGIN_SRC: sh
  718. MAILDIR=$HOME/Maildir
  719. DEFAULT=$MAILDIR/
  720. LOGFILE=$HOME/log/procmail.log
  721. LOGABSTRACT=all
  722. # get spamassassin to check emails
  723. :0fw: .spamassassin.lock
  724. * < 256000
  725. | spamc
  726. # strong spam are discarded
  727. :0
  728. * ^X-Spam-Level: \*\*\*\*\*\*
  729. /dev/null
  730. # weak spam are kept just in case - clear this out every now and then
  731. :0
  732. * ^X-Spam-Level: \*\*\*\*\*
  733. .0-spam/
  734. # otherwise, marginal spam goes here for revision
  735. :0
  736. * ^X-Spam-Level: \*\*
  737. .spam/
  738. #+END_SRC
  739. Save and exit.
  740. #+BEGIN_SRC: bash
  741. su
  742. emacs /usr/bin/filterspam
  743. #+END_SRC
  744. Add the following contents:
  745. #+BEGIN_SRC: bash
  746. #!/bin/bash
  747. USERNAME=$1
  748. MAILDIR=/home/$USERNAME/Maildir/.learn-spam
  749. if [ ! -d "$MAILDIR" ]; then
  750. exit
  751. fi
  752. for f in `ls $MAILDIR/cur`
  753. do
  754. spamc -L spam < "$MAILDIR/cur/$f" > /dev/null
  755. rm "$MAILDIR/cur/$f"
  756. done
  757. for f in `ls $MAILDIR/new`
  758. do
  759. spamc -L spam < "$MAILDIR/new/$f" > /dev/null
  760. rm "$MAILDIR/new/$f"
  761. done
  762. #+END_SRC
  763. Save and exit.
  764. #+BEGIN_SRC: bash
  765. emacs /usr/bin/filterham
  766. #+END_SRC
  767. Add the following contents:
  768. #+BEGIN_SRC: bash
  769. #!/bin/bash
  770. USERNAME=$1
  771. MAILDIR=/home/$USERNAME/Maildir/.learn-ham
  772. if [ ! -d "$MAILDIR" ]; then
  773. exit
  774. fi
  775. for f in `ls $MAILDIR/cur`
  776. do
  777. spamc -L ham < "$MAILDIR/cur/$f" > /dev/null
  778. rm "$MAILDIR/cur/$f"
  779. done
  780. for f in `ls $MAILDIR/new`
  781. do
  782. spamc -L ham < "$MAILDIR/new/$f" > /dev/null
  783. rm "$MAILDIR/new/$f"
  784. done
  785. #+END_SRC
  786. Save and exit.
  787. #+BEGIN_SRC: bash
  788. emacs /etc/crontab
  789. #+END_SRC
  790. Append the following, replacing *myusername* with your username.
  791. #+BEGIN_SRC: bash
  792. */3 * * * * root /usr/bin/filterspam myusername
  793. */3 * * * * root /usr/bin/filterham myusername
  794. #+END_SRC
  795. Save and exit.
  796. #+BEGIN_SRC: bash
  797. chmod 655 /usr/bin/filterspam /usr/bin/filterham
  798. service spamassassin restart
  799. service exim4 restart
  800. service cron restart
  801. #+END_SRC
  802. ** Install Dovecot
  803. Install the required packages.
  804. #+BEGIN_SRC: bash
  805. aptitude -y install dovecot-common dovecot-pop3d dovecot-imapd
  806. #+END_SRC
  807. Edit the configuration file.
  808. #+BEGIN_SRC: bash
  809. emacs /etc/dovecot/dovecot.conf
  810. #+END_SRC
  811. Line 26: change:
  812. #+BEGIN_SRC: bash
  813. listen = *
  814. #+END_SRC
  815. Save and exit.
  816. #+BEGIN_SRC: bash
  817. emacs /etc/dovecot/conf.d/10-auth.conf
  818. #+END_SRC
  819. Line 9: uncomment and change (allow plain text auth)
  820. #+BEGIN_SRC: bash
  821. disable_plaintext_auth = no
  822. #+END_SRC
  823. Line 99: add:
  824. #+BEGIN_SRC: bash
  825. auth_mechanisms = plain login
  826. #+END_SRC
  827. Save and exit.
  828. #+BEGIN_SRC: bash
  829. emacs /etc/dovecot/conf.d/10-mail.conf
  830. #+END_SRC
  831. Line 30: uncomment and add:
  832. #+BEGIN_SRC: bash
  833. mail_location = maildir:~/Maildir:LAYOUT=fs
  834. #+END_SRC
  835. Save and exit, then start the dovecot service.
  836. #+BEGIN_SRC: bash
  837. service dovecot restart
  838. #+END_SRC
  839. ** Create Email folders and rules
  840. 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.
  841. We can make a script to make adding mailing list rules easy:
  842. #+BEGIN_SRC: bash
  843. emacs /usr/bin/mailinglistrule
  844. #+END_SRC
  845. Add the following:
  846. #+BEGIN_SRC: bash
  847. #!/bin/bash
  848. MYUSERNAME=$1
  849. MAILINGLIST=$2
  850. SUBJECTTAG=$3
  851. MUTTRC=/home/$MYUSERNAME/.muttrc
  852. PM=/home/$MYUSERNAME/.procmailrc
  853. LISTDIR=/home/$MYUSERNAME/Maildir/$MAILINGLIST
  854. if [ ! -d "$LISTDIR" ]; then
  855. mkdir -m 700 $LISTDIR
  856. mkdir -m 700 $LISTDIR/tmp
  857. mkdir -m 700 $LISTDIR/new
  858. mkdir -m 700 $LISTDIR/cur
  859. fi
  860. chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR
  861. echo "" >> $PM
  862. echo ":0" >> $PM
  863. echo " * ^Subject:.*()\[$SUBJECTTAG\]" >> $PM
  864. echo "$LISTDIR/new" >> $PM
  865. chown $MYUSERNAME:$MYUSERNAME $PM
  866. if [ ! -f "$MUTTRC" ]; then
  867. cp /etc/Muttrc $MUTTRC
  868. chown $MYUSERNAME:$MYUSERNAME $MUTTRC
  869. fi
  870. #+END_SRC
  871. Save and exit, then make the script executable.
  872. #+BEGIN_SRC: bash
  873. chmod +x /usr/bin/mailinglistrule
  874. #+END_SRC
  875. 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.
  876. #+BEGIN_SRC: bash
  877. mailinglistrule myusername mailinglistname subjecttag
  878. #+END_SRC
  879. Repeat this command for as many mailing lists as you need. Then edit your local Mutt configuration.
  880. #+BEGIN_SRC: bash
  881. emacs /home/myusername/.muttrc
  882. #+END_SRC
  883. Search for the *mailboxes* variable and add entries for the mailing lists you just created. For example:
  884. #+BEGIN_SRC: bash
  885. mailboxes = =Sent =mailinglistname
  886. #+END_SRC
  887. Then save and exit.
  888. ** Setting up a web site
  889. #+BEGIN_VERSE
  890. /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./
  891. -- Tim Berners-Lee
  892. #+END_VERSE
  893. Edit the apache configuration so that it doesn't run out of memory if there are a lot of connections.
  894. #+BEGIN_SRC: bash
  895. su
  896. emacs /etc/apache2/apache2.conf
  897. #+END_SRC
  898. Search for MaxClients and replace the value with 6. As an example the settings should look something like this:
  899. #+BEGIN_SRC: bash
  900. <IfModule mpm_prefork_module>
  901. StartServers 3
  902. MinSpareServers 3
  903. MaxSpareServers 5
  904. MaxClients 6
  905. MaxRequestsPerChild 0
  906. </IfModule>
  907. <IfModule mpm_worker_module>
  908. StartServers 2
  909. MinSpareThreads 25
  910. MaxSpareThreads 75
  911. ThreadLimit 64
  912. ThreadsPerChild 25
  913. MaxClients 6
  914. MaxRequestsPerChild 0
  915. </IfModule>
  916. <IfModule mpm_event_module>
  917. StartServers 2
  918. MinSpareThreads 25
  919. MaxSpareThreads 75
  920. ThreadLimit 64
  921. ThreadsPerChild 25
  922. MaxClients 6
  923. MaxRequestsPerChild 0
  924. </IfModule>
  925. #+END_SRC
  926. Then save and exit In the examples below replace /mydomainname.com/ with your own domain name.
  927. #+BEGIN_SRC: bash
  928. export HOSTNAME=mydomainname.com
  929. mkdir /var/www/$HOSTNAME
  930. mkdir /var/www/$HOSTNAME/htdocs
  931. emacs /etc/apache2/sites-available/$HOSTNAME
  932. #+END_SRC
  933. The Apache configuration for the site should look something like the following. Replace /mydonainname.com/ with the site domain name.
  934. #+BEGIN_SRC: bash
  935. <VirtualHost *:80>
  936. ServerAdmin myusername@mydomainname.com
  937. ServerName mydomainname.com
  938. DocumentRoot /var/www/mydomainname.com/htdocs
  939. <Directory />
  940. Options FollowSymLinks
  941. AllowOverride All
  942. </Directory>
  943. <Directory /var/www/mydomainname.com/htdocs/>
  944. Options All
  945. AllowOverride All
  946. Order allow,deny
  947. allow from all
  948. </Directory>
  949. # Don't serve .php~ or .php# files created by emacs
  950. <Files ~ "(^#.*#|~|\.sw[op])$">
  951. Order allow,deny
  952. Deny from all
  953. </Files>
  954. <IfModule headers_module>
  955. Header set X-Content-Type-Options nosniff
  956. Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate, private"
  957. Header set Pragma no-cache
  958. </IfModule>
  959. <Files .htaccess>
  960. deny from all
  961. </Files>
  962. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  963. <Directory "/usr/lib/cgi-bin">
  964. AllowOverride All
  965. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  966. Order allow,deny
  967. Allow from all
  968. </Directory>
  969. ErrorLog ${APACHE_LOG_DIR}/error.log
  970. # Possible values include: debug, info, notice, warn, error, crit,
  971. # alert, emerg.
  972. LogLevel error
  973. CustomLog ${APACHE_LOG_DIR}/access.log combined
  974. </VirtualHost>
  975. <IfModule mod_ssl.c>
  976. <VirtualHost *:443>
  977. ServerAdmin myusername@mydomainname.com
  978. ServerName mydomainname.com
  979. DocumentRoot /var/www/mydomainname.com/htdocs
  980. <Directory />
  981. Options FollowSymLinks
  982. AllowOverride All
  983. </Directory>
  984. <Directory /var/www/mydomainname.com/htdocs/>
  985. Options All
  986. AllowOverride All
  987. Order allow,deny
  988. allow from all
  989. </Directory>
  990. # Don't serve .php~ or .php# files created by emacs
  991. <Files ~ "(^#.*#|~|\.sw[op])$">
  992. Order allow,deny
  993. Deny from all
  994. </Files>
  995. <IfModule headers_module>
  996. Header set X-Content-Type-Options nosniff
  997. Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate, private"
  998. Header set Pragma no-cache
  999. </IfModule>
  1000. <Files .htaccess>
  1001. deny from all
  1002. </Files>
  1003. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  1004. <Directory "/usr/lib/cgi-bin">
  1005. AllowOverride All
  1006. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  1007. Order allow,deny
  1008. Allow from all
  1009. </Directory>
  1010. ErrorLog ${APACHE_LOG_DIR}/error.log
  1011. # Possible values include: debug, info, notice, warn, error, crit,
  1012. # alert, emerg.
  1013. LogLevel error
  1014. CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
  1015. # SSL Engine Switch:
  1016. # Enable/Disable SSL for this virtual host.
  1017. SSLEngine on
  1018. # A self-signed certificate
  1019. SSLCertificateFile /etc/ssl/certs/mydomainname.com.crt
  1020. SSLCertificateKeyFile /etc/ssl/private/mydomainname.com.key
  1021. # Options based on bettercrypto.org
  1022. SSLProtocol All -SSLv2 -SSLv3
  1023. SSLHonorCipherOrder On
  1024. SSLCompression off
  1025. 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
  1026. # Add six earth month HSTS header for all users ...
  1027. Header add Strict-Transport-Security "max-age=15768000"
  1028. # If you want to protect all subdomains , use the following header
  1029. # ALL subdomains HAVE TO support https if you use this !
  1030. # Strict-Transport-Security: max-age=15768000 ; includeSubDomains
  1031. # SSL Engine Options:
  1032. # Set various options for the SSL engine.
  1033. # o FakeBasicAuth:
  1034. # Translate the client X.509 into a Basic Authorisation. This means that
  1035. # the standard Auth/DBMAuth methods can be used for access control. The
  1036. # user name is the `one line' version of the client's X.509 certificate.
  1037. # Note that no password is obtained from the user. Every entry in the user
  1038. # file needs this password: `xxj31ZMTZzkVA'.
  1039. # o ExportCertData:
  1040. # This exports two additional environment variables: SSL_CLIENT_CERT and
  1041. # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
  1042. # server (always existing) and the client (only existing when client
  1043. # authentication is used). This can be used to import the certificates
  1044. # into CGI scripts.
  1045. # o StdEnvVars:
  1046. # This exports the standard SSL/TLS related `SSL_*' environment variables.
  1047. # Per default this exportation is switched off for performance reasons,
  1048. # because the extraction step is an expensive operation and is usually
  1049. # useless for serving static content. So one usually enables the
  1050. # exportation for CGI and SSI requests only.
  1051. # o StrictRequire:
  1052. # This denies access when "SSLRequireSSL" or "SSLRequire" applied even
  1053. # under a "Satisfy any" situation, i.e. when it applies access is denied
  1054. # and no other module can change it.
  1055. # o OptRenegotiate:
  1056. # This enables optimized SSL connection renegotiation handling when SSL
  1057. # directives are used in per-directory context.
  1058. #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
  1059. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  1060. SSLOptions +StdEnvVars
  1061. </FilesMatch>
  1062. <Directory /usr/lib/cgi-bin>
  1063. SSLOptions +StdEnvVars
  1064. </Directory>
  1065. # SSL Protocol Adjustments:
  1066. # The safe and default but still SSL/TLS standard compliant shutdown
  1067. # approach is that mod_ssl sends the close notify alert but doesn't wait for
  1068. # the close notify alert from client. When you need a different shutdown
  1069. # approach you can use one of the following variables:
  1070. # o ssl-unclean-shutdown:
  1071. # This forces an unclean shutdown when the connection is closed, i.e. no
  1072. # SSL close notify alert is send or allowed to received. This violates
  1073. # the SSL/TLS standard but is needed for some brain-dead browsers. Use
  1074. # this when you receive I/O errors because of the standard approach where
  1075. # mod_ssl sends the close notify alert.
  1076. # o ssl-accurate-shutdown:
  1077. # This forces an accurate shutdown when the connection is closed, i.e. a
  1078. # SSL close notify alert is send and mod_ssl waits for the close notify
  1079. # alert of the client. This is 100% SSL/TLS standard compliant, but in
  1080. # practice often causes hanging connections with brain-dead browsers. Use
  1081. # this only for browsers where you know that their SSL implementation
  1082. # works correctly.
  1083. # Notice: Most problems of broken clients are also related to the HTTP
  1084. # keep-alive facility, so you usually additionally want to disable
  1085. # keep-alive for those clients, too. Use variable "nokeepalive" for this.
  1086. # Similarly, one has to force some clients to use HTTP/1.0 to workaround
  1087. # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
  1088. # "force-response-1.0" for this.
  1089. BrowserMatch "MSIE [2-6]" \
  1090. nokeepalive ssl-unclean-shutdown \
  1091. downgrade-1.0 force-response-1.0
  1092. # MSIE 7 and newer should be able to use keepalive
  1093. BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  1094. </VirtualHost>
  1095. </IfModule>
  1096. #+END_SRC
  1097. Then to enable the site:
  1098. #+BEGIN_SRC: bash
  1099. a2ensite
  1100. a2dissite default
  1101. a2dissite default-ssl
  1102. a2enmod rewrite
  1103. a2enmod headers
  1104. #+END_SRC
  1105. Ensure that "NameVirtualHost *:443" is added to /etc/apache2/ports.conf. It should look something like the following:
  1106. #+BEGIN_SRC: bash
  1107. NameVirtualHost *:80
  1108. Listen 80
  1109. <IfModule mod_ssl.c>
  1110. NameVirtualHost *:443
  1111. Listen 443
  1112. </IfModule>
  1113. <IfModule mod_gnutls.c>
  1114. NameVirtualHost *:443
  1115. Listen 443
  1116. </IfModule>
  1117. #+END_SRC
  1118. Create a self-signed certificate. The passphrase isn't important and will be removed, so make it easy (such as "password").
  1119. #+BEGIN_SRC: bash
  1120. emacs makecert
  1121. #+END_SRC
  1122. Enter the following:
  1123. #+BEGIN_SRC: bash
  1124. #!/bin/bash
  1125. HOSTNAME=$1
  1126. openssl genrsa -des3 -out $HOSTNAME.key 1024
  1127. openssl req -new -x509 -nodes -sha1 -days 3650 -key $HOSTNAME.key -out $HOSTNAME.crt
  1128. openssl rsa -in $HOSTNAME.key -out $HOSTNAME.new.key
  1129. cp $HOSTNAME.new.key $HOSTNAME.key
  1130. rm $HOSTNAME.new.key
  1131. cp $HOSTNAME.key /etc/ssl/private
  1132. chmod 400 /etc/ssl/private/$HOSTNAME.key
  1133. cp $HOSTNAME.crt /etc/ssl/certs
  1134. shred -zu $HOSTNAME.key $HOSTNAME.crt
  1135. a2enmod ssl
  1136. service apache2 restart
  1137. #+END_SRC
  1138. Save and exit.
  1139. #+BEGIN_SRC: bash
  1140. chmod +x makecert
  1141. ./makecert mydomainname.com
  1142. #+END_SRC
  1143. Enter some trivial password for the key file. The password will be removed as part of the makecert script. 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.
  1144. 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.
  1145. ** Accessing your Email
  1146. *** Mutt email client
  1147. #+BEGIN_VERSE
  1148. /I dreamt last night that I was living in a surveillance state. I woke up and… I’m still in a surveillance state./
  1149. -- Conrad Kramer
  1150. #+END_VERSE
  1151. #+BEGIN_SRC: bash
  1152. apt-get install mutt-patched lynx abook
  1153. exit
  1154. mkdir ~/.mutt
  1155. echo "text/html; lynx -dump -width=78 -nolist %s | sed ‘s/^ //’; copiousoutput; needsterminal; nametemplate=%s.html" > ~/.mutt/mailcap
  1156. #+END_SRC
  1157. Save and exit.
  1158. #+BEGIN_SRC: bash
  1159. su
  1160. emacs /etc/Muttrc
  1161. #+END_SRC
  1162. Append the following:
  1163. #+BEGIN_SRC: bash
  1164. set mbox_type=Maildir
  1165. set folder="~/Maildir"
  1166. set mask="!^\\.[^.]"
  1167. set mbox="~/Maildir"
  1168. set record="+Sent"
  1169. set postponed="+Drafts"
  1170. set trash="+Trash"
  1171. set spoolfile="~/Maildir"
  1172. auto_view text/x-vcard text/html text/enriched
  1173. set editor="emacsclient %s"
  1174. set header_cache="+.cache"
  1175. macro index S "<tag-prefix><save-message>=.learn-spam<enter>" "move to learn-spam"
  1176. macro pager S "<save-message>=.learn-spam<enter>" "move to learn-spam"
  1177. macro index H "<tag-prefix><copy-message>=.learn-ham<enter>" "copy to learn-ham"
  1178. macro pager H "<copy-message>=.learn-ham<enter>" "copy to learn-ham"
  1179. # set up the sidebar
  1180. set sidebar_width=12
  1181. set sidebar_visible=yes
  1182. set sidebar_delim='|'
  1183. set sidebar_sort=yes
  1184. set rfc2047_parameters
  1185. # Show inbox and sent items
  1186. mailboxes = =Sent
  1187. # Alter these colours as needed for maximum bling
  1188. color sidebar_new yellow default
  1189. color normal white default
  1190. color hdrdefault brightcyan default
  1191. color signature green default
  1192. color attachment brightyellow default
  1193. color quoted green default
  1194. color quoted1 white default
  1195. color tilde blue default
  1196. # ctrl-n, ctrl-p to select next, prev folder
  1197. # ctrl-o to open selected folder
  1198. bind index \Cp sidebar-prev
  1199. bind index \Cn sidebar-next
  1200. bind index \Co sidebar-open
  1201. bind pager \Cp sidebar-prev
  1202. bind pager \Cn sidebar-next
  1203. bind pager \Co sidebar-open
  1204. # ctrl-b toggles sidebar visibility
  1205. macro index \Cb '<enter-command>toggle sidebar_visible<enter><refresh>' "toggle sidebar"
  1206. macro pager \Cb '<enter-command>toggle sidebar_visible<enter><redraw-screen>' "toggle sidebar"
  1207. # esc-m Mark new messages as read
  1208. macro index <esc>m "T~N<enter>;WNT~O<enter>;WO\CT~T<enter>" "mark all messages read"
  1209. #+END_SRC
  1210. Save and exit.
  1211. #+BEGIN_SRC: bash
  1212. emacs /etc/mail/spamassassin/local.cf
  1213. #+END_SRC
  1214. Uncomment *use_bayes*, *bayes_auto_learn*
  1215. Save and exit, then run:
  1216. #+BEGIN_SRC: bash
  1217. service spamassassin restart
  1218. #+END_SRC
  1219. Now to add an address book:
  1220. #+BEGIN_SRC: bash
  1221. emacs ~/.muttrc
  1222. #+END_SRC
  1223. Append the following:
  1224. #+BEGIN_SRC: bash
  1225. set alias_file=~/.mutt-alias
  1226. source ~/.mutt-alias
  1227. set query_command= "abook --mutt-query '%s'"
  1228. macro index,pager A "<pipe-message>abook --add-email-quiet<return>" "add the sender address to abook"
  1229. #+END_SRC
  1230. Then save and exit.
  1231. #+BEGIN_SRC: bash
  1232. touch ~/.mutt-alias
  1233. #+END_SRC
  1234. 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.
  1235. 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.
  1236. Some useful keys to know are:
  1237. | ESC / | Search for text within message contents |
  1238. | "/" | Search for text within headers |
  1239. | * | Move to the last message |
  1240. | TAB | Move to the next unread message |
  1241. | d | Delete a message |
  1242. | u | Undelete a mail which is pending deletion |
  1243. | $ | Delete all messages selected and check for new messages |
  1244. | a | Add to the address book |
  1245. | m | Send a new mail |
  1246. | ESC-m | Mark all messages as having been read |
  1247. | S | Mark a message as spam |
  1248. | H | Mark a message as ham |
  1249. | CTRL-b | Toggle side bar on/off |
  1250. | CTRL-n | Next mailbox (on side bar) |
  1251. | CTRL-p | Previous mailbox (on side bar) |
  1252. | CTRL-o | Open mailbox (on side bar) |
  1253. *** K9 Android client
  1254. #+BEGIN_VERSE
  1255. /The surveillance state is robust. It is robust politically, legally, and technically./
  1256. -- Bruce Schneier
  1257. #+END_VERSE
  1258. **** Incoming server settings
  1259. * Select settings/account settings
  1260. * Select Fetching mail/incoming server
  1261. * Enter your username and password
  1262. * IMAP server should be your domain name
  1263. * Security: SSL/TLS (always)
  1264. * Authentication: Plain
  1265. * Port: 993
  1266. **** Outgoing (SMTP) server settings
  1267. * Select settings/account settings
  1268. * Select Sending mail/outgoing server
  1269. * Set SMTP server to your domain name
  1270. * Set Security to SSL/TLS (always)
  1271. * Set port to 465
  1272. * Set authentication to PLAIN
  1273. * Enter your username and password
  1274. * Accept the SSL certificate
  1275. **** Folders
  1276. 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*.
  1277. If your folder still doesn't show up then press the *menu button*, select *show folders* and select *all folders*.
  1278. *** Webmail
  1279. #+BEGIN_VERSE
  1280. /Most of the information extracted is "content", such as recordings of phone calls or the substance of email messages./
  1281. -- From a 2013 Guardian article on GCHQ/NSA bulk internet data interception.
  1282. #+END_VERSE
  1283. 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.
  1284. Install dependencies.
  1285. #+BEGIN_SRC: bash
  1286. apt-get install libapache2-mod-authz-unixgroup
  1287. #+END_SRC
  1288. Create a mysql database, specifying a password which should be a long random string generated with a password manager such as KeepassX.
  1289. #+BEGIN_SRC: bash
  1290. mysql -u root -p
  1291. create database roundcubemail;
  1292. CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'roundcubepassword';
  1293. GRANT ALL PRIVILEGES ON roundcubemail.* TO 'roundcube'@'localhost';
  1294. quit
  1295. #+END_SRC
  1296. Download roundcube.
  1297. #+BEGIN_SRC: bash
  1298. cd /tmp
  1299. wget http://freedombone.uk.to/roundcubemail.tar.gz
  1300. #+END_SRC
  1301. Verify it.
  1302. #+BEGIN_SRC: bash
  1303. sha256sum roundcubemail.tar.gz
  1304. e8a311b22a8e1f70abb72ed9551cc9233cf6c5221f1eebf1ae64974117e3148b roundcubemail.tar.gz
  1305. #+END_SRC
  1306. Extract the files.
  1307. #+BEGIN_SRC: bash
  1308. tar -xzvf roundcubemail.tar.gz
  1309. export HOSTNAME=mydomainname.com
  1310. cp -r roundcubemail-* /var/www/$HOSTNAME/htdocs/mail
  1311. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/mail/temp
  1312. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/mail/logs
  1313. rm /var/www/$HOSTNAME/htdocs/mail/.htaccess
  1314. #+END_SRC
  1315. Edit your web site configuration.
  1316. #+BEGIN_SRC: bash
  1317. emacs /etc/apache2/sites-available/$HOSTNAME
  1318. #+END_SRC
  1319. Within the 80 VirtualHost section add the following:
  1320. #+BEGIN_SRC: bash
  1321. <Directory /var/www/mydomainname.com/htdocs/mail>
  1322. deny from all
  1323. </Directory>
  1324. #+END_SRC
  1325. Within the 443 VirtualHost section add the following:
  1326. #+BEGIN_SRC: bash
  1327. <Directory /var/www/mydomainname.com/htdocs/mail>
  1328. Options Indexes FollowSymLinks MultiViews
  1329. AllowOverride All
  1330. Order allow,deny
  1331. allow from all
  1332. </Directory>
  1333. #+END_SRC
  1334. Save and exit, then restart Apache.
  1335. #+BEGIN_SRC: bash
  1336. service apache2 restart
  1337. #+END_SRC
  1338. Now with a browser visit https://mydomainname.com/mail/installer. Scroll down and click "next". Give your webmail site a product name.
  1339. The *spellcheck_engine* option being limited to Google is slightly concerning in terms of privacy and security, but seems not to be implemented.
  1340. Change the *database password* to the password you gave when creating the MySql database above.
  1341. Set *smtp_port* to 465.
  1342. Click *create config*
  1343. Click download to download the file.
  1344. In a terminal on your local machine (not logged into the BBB):
  1345. #+BEGIN_SRC: bash
  1346. cd ~/Downloads
  1347. scp config.inc.php myusername@mydomainname.com:/home/myusername
  1348. #+END_SRC
  1349. Then in a terminal ssh'd into the BBB:
  1350. #+BEGIN_SRC: bash
  1351. mv /home/myusername/config.inc.php /var/www/$HOSTNAME/htdocs/mail/config
  1352. chmod 755 /var/www/$HOSTNAME/htdocs/mail/config/config.inc.php
  1353. #+END_SRC
  1354. Click *continue*.
  1355. Click *initialize database*.
  1356. Under *Test SMTP config* you can use a [[mailinator.com]] address to check that mail can be sent.
  1357. Now we can delete the installer.
  1358. #+BEGIN_SRC: bash
  1359. rm -rf /var/www/$HOSTNAME/htdocs/mail/installer
  1360. #+END_SRC
  1361. Now with a browser navigate to https://mydomainname.com/mail and log in.
  1362. 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.
  1363. 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.
  1364. *** Thunderbird
  1365. #+BEGIN_VERSE
  1366. /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./
  1367. -- Brian Spector, on the shutting down of the PrivateSky encrypted email service
  1368. #+END_VERSE
  1369. 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.
  1370. The following instructions should be carried out on the client machines (laptop, etc), not on the BBB itself.
  1371. **** Initial setup
  1372. Install *Thunderbird* and *Enigmail*. How you do this just depends upon your distro and software manager or "app store".
  1373. Open Thinderbird
  1374. Select "*Skip this and use existing email*"
  1375. Enter your name, email address (myusername@mydomainname.com) and the password for your user (the one from [[Add a user]]).
  1376. You'll get a message saying "/Thunderbird failed to find the settings/"
  1377. The settings should be as follows, substituting /mydomainname.com/ for your domain name and /myusername/ for the username given previously in [[Add a user]].
  1378. * Incoming: IMAP, mydomainname.com, 993, SSL/TLS, Normal Password
  1379. * Outgoing: SMTP, mydomainname.com, 465, SSL/TLS, Normal Password
  1380. * Username: myusername
  1381. Click *Done*.
  1382. Click *Get Certificate* and make sure "*permanently store this exception*" is selected", then click *Store Security Exception*.
  1383. 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.
  1384. Select "*Yes, I want to sign all of my email*"
  1385. Select "*No, I will create per-recipient rules*"
  1386. Select "*yes*" to change default settings.
  1387. **** If you have existing GPG key
  1388. Export your GPG public and private keys.
  1389. #+BEGIN_SRC: bash
  1390. gpg --output ~/public_key.txt --armor --export KEY_ID
  1391. gpg --output ~/private_key.txt --armor --export-secret-key KEY_ID
  1392. #+END_SRC
  1393. Select "*I have existing public and private keys*".
  1394. Select your public and private GPG exported key files.
  1395. Select the account which you want to use and click *Next*, *Next* and *Finish*.
  1396. Remove your exported key files.
  1397. #+BEGIN_SRC: bash
  1398. shred -zu ~/public_key.txt
  1399. shred -zu ~/private_key.txt
  1400. #+END_SRC
  1401. **** If you don't have any existing GPG or PGP key
  1402. Select "*I want to create a new key pair*"
  1403. Enter a passphrase and click *Next* a couple of times.
  1404. Click *Generate Certificate* to generate a revocation certificate.
  1405. Enter the passphrase which you gave previously.
  1406. Click *Finish*
  1407. 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.
  1408. 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.
  1409. **** Using for the first time
  1410. Click on the Thunderbird menu, which looks like three horizontal bars on the right hand side.
  1411. Hover over *preferences* and then *Account settings*.
  1412. Select *Synchronization & Storage*.
  1413. Make sure that *Keep messages for this account on this computer* is unticked, then click *Ok*.
  1414. Click on *Inbox*. Depending upon how much email you have it may take a while to import the subject lines.
  1415. Note that when sending an email for the first time you will also need to accept the SSL certificate.
  1416. 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.
  1417. **** Making folders visible
  1418. 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:
  1419. *Menu*, hover over *Preferences*, select *Account Settings*, select *Server Settings* then click on the *Advanced* button.
  1420. 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.
  1421. ** Install a Blog
  1422. #+BEGIN_VERSE
  1423. /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./
  1424. -- Nick Cohen
  1425. #+END_VERSE
  1426. 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.
  1427. 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.
  1428. Download flatpress.
  1429. #+BEGIN_SRC: bash
  1430. cd /tmp
  1431. wget http://freedombone.uk.to/flatpress.tar.gz
  1432. #+END_SRC
  1433. Verify the download:
  1434. #+BEGIN_SRC: bash
  1435. sha256sum flatpress.tar.gz
  1436. 6312a49aab5aabd6371518dcaf081f489dff04d001bc34b4fe3f2a81170bbd4e flatpress.tar.gz
  1437. #+END_SRC
  1438. Extract and install it.
  1439. #+BEGIN_SRC: bash
  1440. tar -xzvf flatpress.tar.gz
  1441. cd flatpress-*
  1442. cp -r * /var/www/$HOSTNAME/htdocs
  1443. rm -rf flatpress-*
  1444. rm -f flatpress.tar.gz
  1445. #+END_SRC
  1446. 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
  1447. ** Install an IRC server
  1448. #+BEGIN_VERSE
  1449. /Give me the liberty to know, to utter, and to argue freely according to conscience, above all liberties./
  1450. -- John Milton
  1451. #+END_VERSE
  1452. *** Base install
  1453. 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.
  1454. First install some dependencies.
  1455. #+BEGIN_SRC: bash
  1456. apt-get update
  1457. apt-get install build-essential openssl libssl-dev
  1458. #+END_SRC
  1459. Then get the source code for ircd-hybrid.
  1460. #+BEGIN_SRC: bash
  1461. cd /tmp
  1462. mkdir hybrid
  1463. cd hybrid
  1464. apt-get source ircd-hybrid
  1465. #+END_SRC
  1466. Modify the source code to include SSL security.
  1467. #+BEGIN_SRC: bash
  1468. emacs ircd-hybrid-*/debian/rules
  1469. #+END_SRC
  1470. Beneath MAXCLIENTS add the line:
  1471. #+BEGIN_SRC: bash
  1472. USE_OPENSSL = 1
  1473. #+END_SRC
  1474. Then save and exit. Now we can build the debian package for ircd-hybrid and install it.
  1475. #+BEGIN_SRC: bash
  1476. cd ircd-hybrid-*
  1477. dpkg-buildpackage -rfakeroot -uc -b
  1478. cd ..
  1479. dpkg -i ircd-hybrid_*.deb
  1480. #+END_SRC
  1481. 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.
  1482. #+BEGIN_SRC: bash
  1483. emacs /etc/ircd-hybrid/ircd.conf
  1484. #+END_SRC
  1485. Set *name* to the name of your server, and set a description.
  1486. Set a *network_name* and *network_desc*. The network name should not contain any spaces.
  1487. Set max_clients to 20, or however many you expect that you'll typically need.
  1488. Within the admin section set your *name* and *email*.
  1489. Within the *listen* section set host to your fixed IP address (in the earlier
  1490. sections it was 192.168.1.60).
  1491. Within the *auth* section set user = "*@192.168.1.60" - or whatever the fixed IP address of the BBB is on your network.
  1492. 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.
  1493. Save and exit, then restart the IRC server. Open port 6670 on your internet router and forward it to the BBB.
  1494. Ensure that the configuration is only readable by the root user.
  1495. #+BEGIN_SRC: bash
  1496. chmod 600 /etc/ircd-hybrid/ircd.conf
  1497. #+END_SRC
  1498. *** Channel management
  1499. To to install channel management tools.
  1500. #+BEGIN_SRC: bash
  1501. cd /tmp
  1502. wget http://freedombone.uk.to/hybserv_1.9.4-1_armhf.deb
  1503. #+END_SRC
  1504. Verify it.
  1505. #+BEGIN_SRC: bash
  1506. sha256sum hybserv_1.9.4-1_armhf.deb
  1507. 41bf4eb6e24c87610a80bc14db1103a57484835510eea7e4ba9709c523318615 hybserv_1.9.4-1_armhf.deb
  1508. #+END_SRC
  1509. Install it.
  1510. #+BEGIN_SRC: bash
  1511. dpkg -i hybserv_1.9.4-1_armhf.deb
  1512. #+END_SRC
  1513. Make a md5 version of the password for the IRC server operator.
  1514. #+BEGIN_SRC: bash
  1515. /usr/bin/mkpasswd <myoperatorpassword>
  1516. #+END_SRC
  1517. Edit the ircd-hybrid configuration.
  1518. #+BEGIN_SRC: bash
  1519. emacs /etc/ircd-hybrid/ircd.conf
  1520. #+END_SRC
  1521. Enter the md5 password which you previously created within the /operator/ section. Also change /user/ to:
  1522. #+BEGIN_SRC: bash
  1523. user = "*@*";
  1524. #+END_SRC
  1525. Then save and exit.
  1526. #+BEGIN_SRC: bash
  1527. emacs /etc/hybserv/hybserv.conf
  1528. #+END_SRC
  1529. 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/.
  1530. #+BEGIN_SRC: bash
  1531. A:mynickname <myemailaddress>
  1532. N:irc.mydomainname.com:Hybrid services
  1533. O:*@*:#MD5 PASSWORD HERE#:root:segj (comment out other Q: lines)
  1534. S:mysendacceptpassword:192.168.1.60:6670 (remove the other two services)
  1535. #+END_SRC
  1536. Also remove the line *#NOT-EDITED#*, then save and exit.
  1537. Now we need to restart the ircd and hybrid server to make things work:
  1538. #+BEGIN_SRC: bash
  1539. service ircd-hybrid restart
  1540. service hybserv start
  1541. #+END_SRC
  1542. *** Usage
  1543. On another computer (not the BBB).
  1544. #+BEGIN_SRC: bash
  1545. sudo apt-get install irssi
  1546. irssi
  1547. #+END_SRC
  1548. 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".
  1549. #+BEGIN_SRC: bash
  1550. /server add -auto -network mynetwork -ssl mydonainname.com 6670 mysendacceptpassword
  1551. /connect mydomainname.com
  1552. /channel add -auto #mychannel mynetwork channelpassword
  1553. /network add -nick mynick mynetwork
  1554. /join #mychannel
  1555. /msg -servername chanserv REGISTER #mychannel channelpassword
  1556. /msg -servername chanserv set #mychannel mlock +k channelpassword
  1557. #+END_SRC
  1558. If you edit the irssi config file:
  1559. #+BEGIN_SRC: bash
  1560. emacs ~/.irssi/config
  1561. #+END_SRC
  1562. It should look something like this:
  1563. #+BEGIN_SRC: bash
  1564. {
  1565. address = "mydomainname.com";
  1566. chatnet = "mynetwork";
  1567. port = "6670";
  1568. password = "mysendacceptpassword";
  1569. use_ssl = "yes";
  1570. ssl_verify = "no";
  1571. autoconnect = "yes";
  1572. },
  1573. #+END_SRC
  1574. If you're not using a self-signed certificate (self-signed is the default) then you can set *ssl_verify* to "yes".
  1575. ** Install a Jabber/XMPP server
  1576. #+BEGIN_VERSE
  1577. /Well heck, it isn’t that hard to write an instant messaging system./
  1578. --Jeremie Miller
  1579. #+END_VERSE
  1580. *** The Server
  1581. Generate a SSL certificate.
  1582. #+BEGIN_SRC: bash
  1583. openssl ecparam -out /etc/ssl/private/xmpp.pem -name prime256v1
  1584. openssl genpkey -paramfile /etc/ssl/private/xmpp.pem -out /etc/ssl/private/xmpp.key
  1585. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  1586. #+END_SRC
  1587. 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:
  1588. #+BEGIN_SRC: bash
  1589. openssl genrsa -out /etc/ssl/private/xmpp.key 4096
  1590. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  1591. #+END_SRC
  1592. Change permissions.
  1593. #+BEGIN_SRC: bash
  1594. chmod 600 /etc/ssl/private/xmpp.key
  1595. chmod 600 /etc/ssl/certs/xmpp.crt
  1596. chown prosody:prosody /etc/ssl/private/xmpp.key
  1597. chown prosody:prosody /etc/ssl/certs/xmpp.crt
  1598. #+END_SRC
  1599. Install Prosody.
  1600. #+BEGIN_SRC: bash
  1601. apt-get install prosody
  1602. cp -a /etc/prosody/conf.avail/example.com.cfg.lua /etc/prosody/conf.avail/xmpp.cfg.lua
  1603. emacs /etc/prosody/conf.avail/xmpp.cfg.lua
  1604. #+END_SRC
  1605. Change the *VirtualHost* name to your domain name and remove the line below it.
  1606. Set the ssl section to:
  1607. #+BEGIN_SRC: bash
  1608. ssl = {
  1609. key = "/etc/ssl/private/xmpp.key";
  1610. certificate = "/etc/ssl/certs/xmpp.crt";
  1611. }
  1612. #+END_SRC
  1613. And also append the following:
  1614. #+BEGIN_SRC: bash
  1615. modules_enabled = {
  1616. "bosh"; -- Enable mod_bosh
  1617. "tls"; -- Enable mod_tls
  1618. }
  1619. c2s_require_encryption = true
  1620. s2s_require_encryption = true
  1621. #+END_SRC
  1622. Save and exit. Create a symbolic link.
  1623. #+BEGIN_SRC: bash
  1624. ln -sf /etc/prosody/conf.avail/xmpp.cfg.lua /etc/prosody/conf.d/xmpp.cfg.lua
  1625. #+END_SRC
  1626. 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).
  1627. #+BEGIN_SRC: bash
  1628. prosodyctl adduser myusername@mydomainname.com
  1629. #+END_SRC
  1630. Restart the server
  1631. #+BEGIN_SRC: bash
  1632. service prosody restart
  1633. #+END_SRC
  1634. On your internet router/firewall open ports 5222, 5223, 5269, 5280 and 5281 and forward them to the BBB.
  1635. 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.
  1636. *** Managing users
  1637. To add a user:
  1638. #+BEGIN_SRC: bash
  1639. prosodyctl adduser myusername@mydomainname.com
  1640. #+END_SRC
  1641. To change a user password:
  1642. #+BEGIN_SRC: bash
  1643. prosodyctl passwd myusername@mydomainname.com
  1644. #+END_SRC
  1645. To remove a user:
  1646. #+BEGIN_SRC: bash
  1647. prosodyctl deluser myusername@mydomainname.com
  1648. #+END_SRC
  1649. Report the status of the XMPP server:
  1650. #+BEGIN_SRC: bash
  1651. prosodyctl status
  1652. #+END_SRC
  1653. *** Using with Jitsi
  1654. 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.
  1655. Jitsi can be downloaded from https://jitsi.org/
  1656. On your desktop/laptop open Jitsi and select *Options* from the *Tools* menu.
  1657. 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).
  1658. 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.
  1659. 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.
  1660. You can also [[https://www.youtube.com/watch?v=vgx7VSrDGjk][see this video]] as an example of using OTR.
  1661. *** Using with Ubuntu
  1662. 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.
  1663. Open *System Settings* and select *Online Accounts*, *Add account* and then *Jabber*.
  1664. Enter your username (myusername@mydomainname.com) and password.
  1665. 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*.
  1666. *** Using with Android
  1667. There are a few XMPP clients available on Android. Ideally choose ones which support off-the-record messaging. Here are some examples.
  1668. **** Xabber
  1669. Install [[https://f-droid.org/][F-Droid]]
  1670. Search for and install Xabber.
  1671. Add an account and enter your Jabber/XMPP ID and password.
  1672. From the menu select *Settings* then *Security* then *OTR mode*. Set the mode to *Required*.
  1673. Make sure that *Check server certificate* is not checked.
  1674. 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.
  1675. **** Gibberbot
  1676. Install [[https://f-droid.org/][F-Droid]]
  1677. Search for and install Gibberbot, otherwise known as ChatSecure.
  1678. From the menu open *Accounts*
  1679. Select *Add account*
  1680. Change the server port from 0 to 5222
  1681. Done
  1682. Accept unknown certificate? Select *Always*
  1683. Go back to the initial screen and then using the menu you can add contacts and begin chatting.
  1684. ** Social Networking
  1685. #+BEGIN_VERSE
  1686. /Facebook is not your friend, it is a surveillance engine./
  1687. -- Richard Stallman, Free Software Foundation
  1688. #+END_VERSE
  1689. *** Friendica
  1690. **** Installation
  1691. 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.
  1692. 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:
  1693. #+BEGIN_SRC: bash
  1694. emacs /etc/apache2/sites-available/mydomainname.com
  1695. #+END_SRC
  1696. Within the section which begins with *<VirtualHost *:80>* change the following:
  1697. #+BEGIN_SRC: bash
  1698. <Directory /var/www/mydomainname.com/htdocs/>
  1699. deny from all
  1700. </Directory>
  1701. #+END_SRC
  1702. Save and exit, then restart the apache server.
  1703. #+BEGIN_SRC: bash
  1704. service apache2 restart
  1705. #+END_SRC
  1706. Now install some dependencies.
  1707. #+BEGIN_SRC: bash
  1708. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  1709. #+END_SRC
  1710. Enter an admin password for MySQL.
  1711. Create a mysql database.
  1712. #+BEGIN_SRC: bash
  1713. mysql -u root -p
  1714. create database friendica;
  1715. CREATE USER 'friendicaadmin'@'localhost' IDENTIFIED BY 'password';
  1716. GRANT ALL PRIVILEGES ON friendica.* TO 'friendicaadmin'@'localhost';
  1717. quit
  1718. #+END_SRC
  1719. You may need to fix Git SSL problems.
  1720. #+BEGIN_SRC: bash
  1721. git config --global http.sslVerify true
  1722. apt-get install ca-certificates
  1723. cd ~/
  1724. emacs .gitconfig
  1725. #+END_SRC
  1726. The .gitconfig file should look something like this:
  1727. #+BEGIN_SRC: bash
  1728. [http]
  1729. sslVerify = true
  1730. sslCAinfo = /etc/ssl/certs/ca-certificates.crt
  1731. [user]
  1732. email = myusername@mydomainname.com
  1733. name = yourname
  1734. #+END_SRC
  1735. Get the source code.
  1736. #+BEGIN_SRC: bash
  1737. export HOSTNAME=mydomainname.com
  1738. cd /var/www/$HOSTNAME
  1739. mv htdocs htdocs_old
  1740. git clone https://github.com/friendica/friendica.git htdocs
  1741. chmod -R 755 htdocs
  1742. chown -R www-data:www-data htdocs
  1743. chown -R www-data:www-data htdocs/view/smarty3
  1744. git clone https://github.com/friendica/friendica-addons.git htdocs/addon
  1745. #+END_SRC
  1746. 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.
  1747. Install the poller.
  1748. #+BEGIN_SRC: bash
  1749. emacs /etc/crontab
  1750. #+END_SRC
  1751. and append the following, changing mydomainname.com to whatever your domain is.
  1752. #+BEGIN_SRC: bash
  1753. */10 * * * * root cd /var/www/mydomainname.com/htdocs; /usr/bin/php include/poller.php
  1754. #+END_SRC
  1755. Save and exit, then restart cron.
  1756. #+BEGIN_SRC: bash
  1757. service cron restart
  1758. #+END_SRC
  1759. You can improve the speed of Friendica database searches by adding the following indexes:
  1760. #+BEGIN_SRC: bash
  1761. mysql -u root -p
  1762. use friendica;
  1763. CREATE INDEX `uri_received` ON item(`uri`, `received`);
  1764. CREATE INDEX `received_uri` ON item(`received`, `uri`);
  1765. CREATE INDEX `contact-id_created` ON item(`contact-id`, created);
  1766. CREATE INDEX `uid_network_received` ON item(`uid`, `network`, `received`);
  1767. CREATE INDEX `uid_parent` ON item(`uid`, `parent`);
  1768. CREATE INDEX `uid_received` ON item(`uid`, `received`);
  1769. CREATE INDEX `uid_network_commented` ON item(`uid`, `network`, `commented`);
  1770. CREATE INDEX `uid_title` ON item(uid, `title`);
  1771. CREATE INDEX `created_contact-id` ON item(`created`, `contact-id`);
  1772. quit
  1773. #+END_SRC
  1774. Make sure that Friendica doesn't use too much memory.
  1775. #+BEGIN_SRC: bash
  1776. emacs /var/www/$HOSTNAME/htdocs/.htaccess
  1777. #+END_SRC
  1778. Append the following:
  1779. #+BEGIN_SRC: bash
  1780. php_value memory_limit 32M
  1781. #+END_SRC
  1782. The save ane exit.
  1783. **** Backups
  1784. 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.
  1785. #+BEGIN_SRC: bash
  1786. emacs /etc/cron.daily/friendicabackup
  1787. #+END_SRC
  1788. Enter the following
  1789. #+BEGIN_SRC: bash
  1790. #!/bin/sh
  1791. MYSQL_PASSWORD=<mysql root password>
  1792. umask 0077
  1793. # Backup the database
  1794. mysqldump --password=$MYSQL_PASSWORD friendica > /var/backups/friendica_daily.sql
  1795. # Make the backup readable only by root
  1796. chmod 600 /var/backups/friendica_daily.sql
  1797. #+END_SRC
  1798. Save and exit.
  1799. #+BEGIN_SRC: bash
  1800. chmod 600 /etc/cron.daily/friendicabackup
  1801. chmod +x /etc/cron.daily/friendicabackup
  1802. emacs /etc/cron.weekly/friendicabackup
  1803. #+END_SRC
  1804. Enter the following
  1805. #+BEGIN_SRC: bash
  1806. #!/bin/sh
  1807. MYSQL_PASSWORD=<mysql root password>
  1808. umask 0077
  1809. # Backup the database
  1810. mysqldump --password=$MYSQL_PASSWORD friendica > /var/backups/friendica_weekly.sql
  1811. # Make the backup readable only by root
  1812. chmod 600 /var/backups/friendica_weekly.sql
  1813. #+END_SRC
  1814. Save and exit.
  1815. #+BEGIN_SRC: bash
  1816. chmod 600 /etc/cron.weekly/friendicabackup
  1817. chmod +x /etc/cron.weekly/friendicabackup
  1818. #+END_SRC
  1819. **** Recommended configuration
  1820. ***** Admin
  1821. 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.
  1822. 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.
  1823. Under the *themes* section select a few themes, including mobile themes which are suitable for phones or tablets.
  1824. 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.
  1825. 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]].
  1826. ***** Settings
  1827. Each user has their own customisable settings, typically available either via an icon or by an entry on a drop down menu.
  1828. Under *additional features* enable "/richtext editor/", "/post preview/", "/group filter/", "/network filter/", "/edit sent posts/" and "/dislike posts/".
  1829. Under *display settings* select your desktop and mobile themes.
  1830. 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.
  1831. **** To access from an Android device
  1832. ***** App
  1833. 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.
  1834. 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.
  1835. More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
  1836. ***** Mobile Theme
  1837. 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.
  1838. *** Movim
  1839. #+BEGIN_VERSE
  1840. /The way we communicate with others and with ourselves ultimately determines the quality of our lives/
  1841. -- Anthony Robbins
  1842. #+END_VERSE
  1843. Movim is another social networking system based around the XMPP protocol.
  1844. You will need to have previously [[Install a Jabber/XMPP server][installed the Jabber/XMPP server]].
  1845. 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:
  1846. #+BEGIN_SRC: bash
  1847. emacs /etc/apache2/sites-available/mydomainname.com
  1848. #+END_SRC
  1849. Within the section which begins with *<VirtualHost *:80>* add the following:
  1850. #+BEGIN_SRC: bash
  1851. <Directory /var/www/mydomainname.com/htdocs/movim>
  1852. deny from all
  1853. </Directory>
  1854. #+END_SRC
  1855. Within the section which begins with *<VirtualHost *:443>* add the following:
  1856. #+BEGIN_SRC: bash
  1857. <Directory /var/www/mydomainname.com/htdocs/movim>
  1858. Options Indexes FollowSymLinks MultiViews
  1859. AllowOverride All
  1860. Order allow,deny
  1861. allow from all
  1862. </Directory>
  1863. #+END_SRC
  1864. Save and exit, then restart the apache server.
  1865. #+BEGIN_SRC: bash
  1866. service apache2 restart
  1867. #+END_SRC
  1868. Download the source.
  1869. #+BEGIN_SRC: bash
  1870. cd /tmp
  1871. wget http://freedombone.uk.to/movim.tar.gz
  1872. #+END_SRC
  1873. Verify it.
  1874. #+BEGIN_SRC: bash
  1875. sha256sum movim.tar.gz
  1876. 2740ddbedf6cefcc2934759374376643b6cdea4fb7f944ec25098a6868cb499e movim.tar.gz
  1877. #+END_SRC
  1878. Install it.
  1879. #+BEGIN_SRC: bash
  1880. tar -xzvf movim.tar.gz
  1881. export HOSTNAME=mydomainname.com
  1882. cp -r movim-* /var/www/$HOSTNAME/htdocs/movim
  1883. chmod 755 /var/www/$HOSTNAME/htdocs/movim
  1884. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/movim
  1885. #+END_SRC
  1886. Install some MySql prerequisites.
  1887. #+BEGIN_SRC: bash
  1888. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  1889. #+END_SRC
  1890. If necessary, enter an admin password for MySQL.
  1891. Create a mysql database.
  1892. #+BEGIN_SRC: bash
  1893. mysql -u root -p
  1894. create database movim;
  1895. CREATE USER 'movimadmin'@'localhost' IDENTIFIED BY 'movimadminpassword';
  1896. GRANT ALL PRIVILEGES ON movim.* TO 'movimadmin'@'localhost';
  1897. quit
  1898. #+END_SRC
  1899. With a web browser navigate to:
  1900. https://mydomainname.com/movim/admin
  1901. Enter /admin/ as the username and /password/ as the password.
  1902. 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).
  1903. Change the /Environment/ from /Development/ to /Production/.
  1904. 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?)
  1905. Click /Submit/ followed by /Resend/.
  1906. Click on /Database Settings/ and alter the MySql movim database username to /movimadmin/ and password to the password you specified in the previous step.
  1907. 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".
  1908. 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).
  1909. *** Red Matrix
  1910. **** Introduction
  1911. 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.
  1912. **** Prerequisites
  1913. 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.
  1914. 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.
  1915. **** Installation
  1916. 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.
  1917. 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:
  1918. #+BEGIN_SRC: bash
  1919. emacs /etc/apache2/sites-available/mydomainname.com
  1920. #+END_SRC
  1921. Within the section which begins with *<VirtualHost *:80>* change the following:
  1922. #+BEGIN_SRC: bash
  1923. <Directory /var/www/mydomainname.com/htdocs/>
  1924. deny from all
  1925. </Directory>
  1926. #+END_SRC
  1927. Save and exit, then restart the apache server.
  1928. #+BEGIN_SRC: bash
  1929. service apache2 restart
  1930. #+END_SRC
  1931. Now install some dependencies.
  1932. #+BEGIN_SRC: bash
  1933. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  1934. #+END_SRC
  1935. Enter an admin password for MySQL.
  1936. Create a mysql database.
  1937. #+BEGIN_SRC: bash
  1938. mysql -u root -p
  1939. create database redmatrix;
  1940. CREATE USER 'redmatrixadmin'@'localhost' IDENTIFIED BY 'password';
  1941. GRANT ALL PRIVILEGES ON redmatrix.* TO 'redmatrixadmin'@'localhost';
  1942. quit
  1943. #+END_SRC
  1944. You may need to fix Git SSL problems.
  1945. #+BEGIN_SRC: bash
  1946. git config --global http.sslVerify true
  1947. apt-get install ca-certificates
  1948. cd ~/
  1949. emacs .gitconfig
  1950. #+END_SRC
  1951. The .gitconfig file should look something like this:
  1952. #+BEGIN_SRC: bash
  1953. [http]
  1954. sslVerify = true
  1955. sslCAinfo = /etc/ssl/certs/ca-certificates.crt
  1956. [user]
  1957. email = myusername@mydomainname.com
  1958. name = yourname
  1959. #+END_SRC
  1960. Get the source code.
  1961. #+BEGIN_SRC: bash
  1962. export HOSTNAME=mydomainname.com
  1963. cd /var/www/$HOSTNAME
  1964. mv htdocs htdocs_old
  1965. git clone https://github.com/friendica/red.git htdocs
  1966. chmod -R 755 htdocs
  1967. chown -R www-data:www-data htdocs
  1968. mkdir htdocs/view/tpl/smarty3
  1969. chmod 777 htdocs/view/tpl
  1970. chmod 777 htdocs/view/tpl/smarty3
  1971. git clone https://github.com/friendica/red-addons.git htdocs/addon
  1972. #+END_SRC
  1973. 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.
  1974. Install the poller.
  1975. #+BEGIN_SRC
  1976. emacs /etc/crontab
  1977. #+END_SRC
  1978. and append the following, changing mydomainname.com to whatever your domain is.
  1979. #+BEGIN_SRC
  1980. */10 * * * * root cd /var/www/mydomainname.com/htdocs; /usr/bin/php include/poller.php
  1981. #+END_SRC
  1982. Save and exit, then restart cron.
  1983. #+BEGIN_SRC: bash
  1984. service cron restart
  1985. #+END_SRC
  1986. **** Backups
  1987. 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.
  1988. #+BEGIN_SRC: bash
  1989. emacs /etc/cron.daily/redmatrixbackup
  1990. #+END_SRC
  1991. Enter the following
  1992. #+BEGIN_SRC: bash
  1993. #!/bin/sh
  1994. MYSQL_PASSWORD=<mysql root password>
  1995. umask 0077
  1996. # Backup the database
  1997. mysqldump --password=$MYSQL_PASSWORD redmatrix > /var/backups/redmatrix_daily.sql
  1998. # Make the backup readable only by root
  1999. chmod 600 /var/backups/redmatrix_daily.sql
  2000. #+END_SRC
  2001. Save and exit.
  2002. #+BEGIN_SRC: bash
  2003. chmod 600 /etc/cron.daily/redmatrixbackup
  2004. chmod +x /etc/cron.daily/redmatrixbackup
  2005. emacs /etc/cron.weekly/redmatrixbackup
  2006. #+END_SRC
  2007. Enter the following
  2008. #+BEGIN_SRC: bash
  2009. #!/bin/sh
  2010. MYSQL_PASSWORD=<mysql root password>
  2011. umask 0077
  2012. # Backup the database
  2013. mysqldump --password=$MYSQL_PASSWORD redmatrix > /var/backups/redmatrix_weekly.sql
  2014. # Make the backup readable only by root
  2015. chmod 600 /var/backups/redmatrix_weekly.sql
  2016. #+END_SRC
  2017. Save and exit.
  2018. #+BEGIN_SRC: bash
  2019. chmod 600 /etc/cron.weekly/redmatrixbackup
  2020. chmod +x /etc/cron.weekly/redmatrixbackup
  2021. #+END_SRC
  2022. **** To access from an Android device
  2023. ***** App
  2024. 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.
  2025. 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.
  2026. More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
  2027. ** Install Gopher
  2028. 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.
  2029. To set up a gopher server:
  2030. #+BEGIN_SRC: bash
  2031. apt-get install build-essential
  2032. cd /tmp
  2033. wget http://freedombone.uk.to/geomyidae-current.tgz
  2034. #+END_SRC
  2035. Verify the download:
  2036. #+BEGIN_SRC: bash
  2037. sha256sum geomyidae-current.tgz
  2038. 162f55ab059ab0a9be8e840497795293bbd51c34b1f4564dcdf3f0ddd5c0db31 geomyidae-current.tgz
  2039. #+END_SRC
  2040. Then extract and install it.
  2041. #+BEGIN_SRC: bash
  2042. tar -xzvf geomyidae-current.tgz
  2043. cd geomyidae-*
  2044. make
  2045. make install
  2046. mkdir -p /var/gopher
  2047. #+END_SRC
  2048. 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.
  2049. #+BEGIN_SRC: bash
  2050. emacs /etc/init.d/gopher
  2051. #+END_SRC
  2052. Enter the following:
  2053. #+BEGIN_SRC: bash
  2054. #! /bin/sh
  2055. ### BEGIN INIT INFO
  2056. # Provides: gopher
  2057. # Required-Start: $remote_fs $syslog
  2058. # Required-Stop: $remote_fs $syslog
  2059. # Default-Start: 2 3 4 5
  2060. # Default-Stop: 0 1 6
  2061. # Short-Description: Gopher daemon
  2062. # Description: Gopher daemon
  2063. ### END INIT INFO
  2064. # Do NOT "set -e"
  2065. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  2066. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  2067. DESC="Gopher daemon"
  2068. NAME=geomyidae
  2069. DAEMON=/usr/bin/$NAME
  2070. DAEMON_ARGS="-l /var/log/geomyidae.log -b /var/gopher -p 70"
  2071. PIDFILE=/var/run/$NAME.pid
  2072. SCRIPTNAME=/etc/init.d/$NAME
  2073. # Exit if the package is not installed
  2074. [ -x "$DAEMON" ] || exit 0
  2075. # Read configuration variable file if it is present
  2076. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  2077. # Load the VERBOSE setting and other rcS variables
  2078. . /lib/init/vars.sh
  2079. # Define LSB log_* functions.
  2080. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
  2081. # and status_of_proc is working.
  2082. . /lib/lsb/init-functions
  2083. #
  2084. # Function that starts the daemon/service
  2085. #
  2086. do_start()
  2087. {
  2088. # Return
  2089. # 0 if daemon has been started
  2090. # 1 if daemon was already running
  2091. # 2 if daemon could not be started
  2092. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
  2093. || return 1
  2094. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
  2095. $DAEMON_ARGS \
  2096. || return 2
  2097. # Add code here, if necessary, that waits for the process to be ready
  2098. # to handle requests from services started subsequently which depend
  2099. # on this one. As a last resort, sleep for some time.
  2100. }
  2101. #
  2102. # Function that stops the daemon/service
  2103. #
  2104. do_stop()
  2105. {
  2106. # Return
  2107. # 0 if daemon has been stopped
  2108. # 1 if daemon was already stopped
  2109. # 2 if daemon could not be stopped
  2110. # other if a failure occurred
  2111. start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
  2112. RETVAL="$?"
  2113. [ "$RETVAL" = 2 ] && return 2
  2114. # Wait for children to finish too if this is a daemon that forks
  2115. # and if the daemon is only ever run from this initscript.
  2116. # If the above conditions are not satisfied then add some other code
  2117. # that waits for the process to drop all resources that could be
  2118. # needed by services started subsequently. A last resort is to
  2119. # sleep for some time.
  2120. start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
  2121. [ "$?" = 2 ] && return 2
  2122. # Many daemons don't delete their pidfiles when they exit.
  2123. rm -f $PIDFILE
  2124. return "$RETVAL"
  2125. }
  2126. #
  2127. # Function that sends a SIGHUP to the daemon/service
  2128. #
  2129. do_reload() {
  2130. #
  2131. # If the daemon can reload its configuration without
  2132. # restarting (for example, when it is sent a SIGHUP),
  2133. # then implement that here.
  2134. #
  2135. start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
  2136. return 0
  2137. }
  2138. case "$1" in
  2139. start)
  2140. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  2141. do_start
  2142. case "$?" in
  2143. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  2144. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  2145. esac
  2146. ;;
  2147. stop)
  2148. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  2149. do_stop
  2150. case "$?" in
  2151. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  2152. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  2153. esac
  2154. ;;
  2155. status)
  2156. status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  2157. ;;
  2158. #reload|force-reload)
  2159. #
  2160. # If do_reload() is not implemented then leave this commented out
  2161. # and leave 'force-reload' as an alias for 'restart'.
  2162. #
  2163. #log_daemon_msg "Reloading $DESC" "$NAME"
  2164. #do_reload
  2165. #log_end_msg $?
  2166. #;;
  2167. restart|force-reload)
  2168. #
  2169. # If the "reload" option is implemented then remove the
  2170. # 'force-reload' alias
  2171. #
  2172. log_daemon_msg "Restarting $DESC" "$NAME"
  2173. do_stop
  2174. case "$?" in
  2175. 0|1)
  2176. do_start
  2177. case "$?" in
  2178. 0) log_end_msg 0 ;;
  2179. 1) log_end_msg 1 ;; # Old process is still running
  2180. *) log_end_msg 1 ;; # Failed to start
  2181. esac
  2182. ;;
  2183. *)
  2184. # Failed to stop
  2185. log_end_msg 1
  2186. ;;
  2187. esac
  2188. ;;
  2189. *)
  2190. #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  2191. echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
  2192. exit 3
  2193. ;;
  2194. esac
  2195. :
  2196. #+END_SRC
  2197. Save and exit. Then start the gopher service.
  2198. #+BEGIN_SRC: bash
  2199. chmod +x /etc/init.d/gopher
  2200. update-rc.d gopher defaults
  2201. service gopher start
  2202. #+END_SRC
  2203. 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:
  2204. #+BEGIN_SRC: bash
  2205. gopher://mydomainname.com
  2206. #+END_SRC
  2207. There is a browser addon for Gopher called "overbite". Installing that should enable you to view your site.
  2208. ** Install Owncloud
  2209. #+BEGIN_VERSE
  2210. /It's not water vapour/
  2211. -- Larry Ellison
  2212. #+END_VERSE
  2213. 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.
  2214. *** Server Installation
  2215. Install some dependencies:
  2216. #+BEGIN_SRC: bash
  2217. apt-get install apache2 php5 php5-gd php-xml-parser php5-intl
  2218. apt-get install php5-sqlite php5-mysql smbclient curl libcurl3 php5-curl
  2219. #+END_SRC
  2220. 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.
  2221. #+BEGIN_SRC: bash
  2222. a2dismod php5filter
  2223. apt-get install libapache2-mod-php5
  2224. #+END_SRC
  2225. Ensure that the size of files which may be uploaded or downloaded is large enough.
  2226. #+BEGIN_SRC: bash
  2227. emacs /etc/php5/apache2/php.ini
  2228. #+END_SRC
  2229. Set the following:
  2230. #+BEGIN_SRC: bash
  2231. upload_max_filesize = 512M
  2232. post_max_size = 512M
  2233. #+END_SRC
  2234. Save and exit, then edit your Apache configuration.
  2235. #+BEGIN_SRC: bash
  2236. export HOSTNAME=mydomainname.com
  2237. emacs /etc/apache2/sites-available/$HOSTNAME
  2238. #+END_SRC
  2239. 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.
  2240. #+BEGIN_SRC: bash
  2241. <Directory /var/www/mydomainname.com/htdocs/owncloud>
  2242. Options Indexes FollowSymLinks MultiViews
  2243. AllowOverride All
  2244. Order allow,deny
  2245. allow from all
  2246. </Directory>
  2247. #+END_SRC
  2248. To ensure that nobody logs in insecurely add the following to the 80 VirtualHost section.
  2249. #+BEGIN_SRC: bash
  2250. <Directory /var/www/mydomainname.com/htdocs/owncloud>
  2251. deny from all
  2252. </Directory>
  2253. #+END_SRC
  2254. Save and exit, then restart apache.
  2255. #+BEGIN_SRC: bash
  2256. service apache2 restart
  2257. #+END_SRC
  2258. Download owncloud.
  2259. #+BEGIN_SRC: bash
  2260. cd /tmp
  2261. wget http://freedombone.uk.to/owncloud.tar.bz2
  2262. #+END_SRC
  2263. Verify the download:
  2264. #+BEGIN_SRC: bash
  2265. sha256sum owncloud.tar.bz2
  2266. 92b53fdfa7c4165b83dd2f8447f63928454a5815d08ff2d6165dd1a8969ecbe1 owncloud.tar.bz2
  2267. #+END_SRC
  2268. Extract the archive. This may take a couple of minutes, so don't be alarmed that the system has crashed.
  2269. #+BEGIN_SRC: bash
  2270. export HOSTNAME=mydomainname.com
  2271. tar -xjf owncloud.tar.bz2
  2272. #+END_SRC
  2273. Move the extracted files to your site and set file permissions.
  2274. #+BEGIN_SRC: bash
  2275. cp -r owncloud /var/www/$HOSTNAME/htdocs
  2276. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud/apps
  2277. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud/config
  2278. chown www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud
  2279. #+END_SRC
  2280. Edit the htaccess file for Owncloud.
  2281. #+BEGIN_SRC: bash
  2282. emacs /var/www/$HOSTNAME/htdocs/owncloud/.htaccess
  2283. #+END_SRC
  2284. Set the following.
  2285. #+BEGIN_SRC: bash
  2286. php_value upload_max_filesize 512M
  2287. php_value post_max_size 512M
  2288. php_value memory_limit 32M
  2289. #+END_SRC
  2290. Save and exit.
  2291. With a web browser visit your domain (mydomainname.com/owncloud) and enter an administrator username and password.
  2292. *** Owncloud on Android
  2293. 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.
  2294. ** Install a Wiki
  2295. #+BEGIN_VERSE
  2296. /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./
  2297. -- Tom Barbalet
  2298. #+END_VERSE
  2299. Dokuwiki is based upon flat files, and so is easy to move from one server to another without a lot of database complications.
  2300. Download the wiki.
  2301. #+BEGIN_SRC: bash
  2302. cd /tmp
  2303. wget http://freedombone.uk.to/dokuwiki.tgz
  2304. #+END_SRC
  2305. Verify it.
  2306. #+BEGIN_SRC: bash
  2307. sha256sum dokuwiki.tgz
  2308. 6b126f90979463d9ddaa74acc6f96aa230cfdc789946f241c3646086d9574be8 dokuwiki.tgz
  2309. #+END_SRC
  2310. Then extract and install it.
  2311. #+BEGIN_SRC: bash
  2312. export HOSTNAME=mywikidomainname.com
  2313. tar -xzvf dokuwiki.tgz
  2314. mv /var/www/$HOSTNAME/htdocs /var/www/$HOSTNAME/htdocs_old
  2315. mv dokuwiki /var/www/$HOSTNAME/htdocs
  2316. #+END_SRC
  2317. Edit the Apache configuration for your wiki site.
  2318. #+BEGIN_SRC: bash
  2319. emacs /etc/apache2/sites-available/$HOSTNAME
  2320. #+END_SRC
  2321. The settings should look something like the following. Replace /mywikidomainname.com/ with your wiki domain name.
  2322. #+BEGIN_SRC: bash
  2323. <VirtualHost *:80>
  2324. ServerAdmin myusername@mywikidomainname.com
  2325. ServerName mydomainname.com
  2326. DocumentRoot /var/www/mywikidomainname.com/htdocs
  2327. <Directory /var/www/mywikidomainname.com/htdocs>
  2328. order deny,allow
  2329. allow from all
  2330. </Directory>
  2331. <LocationMatch "/(data|conf|bin|inc)/">
  2332. order allow,deny
  2333. deny from all
  2334. satisfy all
  2335. </LocationMatch>
  2336. <Directory />
  2337. Options FollowSymLinks
  2338. AllowOverride All
  2339. </Directory>
  2340. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  2341. <Directory "/usr/lib/cgi-bin">
  2342. AllowOverride All
  2343. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  2344. Order allow,deny
  2345. Allow from all
  2346. </Directory>
  2347. ErrorLog ${APACHE_LOG_DIR}/error.log
  2348. # Possible values include: debug, info, notice, warn, error, crit,
  2349. # alert, emerg.
  2350. LogLevel error
  2351. CustomLog ${APACHE_LOG_DIR}/access.log combined
  2352. </VirtualHost>
  2353. <IfModule mod_ssl.c>
  2354. <VirtualHost *:443>
  2355. ServerAdmin myusername@mywikidomainname.com
  2356. ServerName mywikidomainname.com
  2357. DocumentRoot /var/www/mywikidomainname.com/htdocs
  2358. <Directory /var/www/mywikidomainname.com/htdocs>
  2359. order deny,allow
  2360. allow from all
  2361. </Directory>
  2362. <LocationMatch "/(data|conf|bin|inc)/">
  2363. order allow,deny
  2364. deny from all
  2365. satisfy all
  2366. </LocationMatch>
  2367. <Directory />
  2368. Options FollowSymLinks
  2369. AllowOverride All
  2370. </Directory>
  2371. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  2372. <Directory "/usr/lib/cgi-bin">
  2373. AllowOverride All
  2374. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  2375. Order allow,deny
  2376. Allow from all
  2377. </Directory>
  2378. ErrorLog ${APACHE_LOG_DIR}/error.log
  2379. # Possible values include: debug, info, notice, warn, error, crit,
  2380. # alert, emerg.
  2381. LogLevel error
  2382. CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
  2383. # SSL Engine Switch:
  2384. # Enable/Disable SSL for this virtual host.
  2385. SSLEngine on
  2386. # A self-signed certificate
  2387. SSLCertificateFile /etc/ssl/certs/mydomainname.com.crt
  2388. SSLCertificateKeyFile /etc/ssl/private/mydomainname.com.key
  2389. # Options based on bettercrypto.org
  2390. SSLProtocol All -SSLv2 -SSLv3
  2391. SSLHonorCipherOrder On
  2392. SSLCompression off
  2393. 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
  2394. # SSL Engine Options:
  2395. # Set various options for the SSL engine.
  2396. # o FakeBasicAuth:
  2397. # Translate the client X.509 into a Basic Authorisation. This means that
  2398. # the standard Auth/DBMAuth methods can be used for access control. The
  2399. # user name is the `one line' version of the client's X.509 certificate.
  2400. # Note that no password is obtained from the user. Every entry in the user
  2401. # file needs this password: `xxj31ZMTZzkVA'.
  2402. # o ExportCertData:
  2403. # This exports two additional environment variables: SSL_CLIENT_CERT and
  2404. # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
  2405. # server (always existing) and the client (only existing when client
  2406. # authentication is used). This can be used to import the certificates
  2407. # into CGI scripts.
  2408. # o StdEnvVars:
  2409. # This exports the standard SSL/TLS related `SSL_*' environment variables.
  2410. # Per default this exportation is switched off for performance reasons,
  2411. # because the extraction step is an expensive operation and is usually
  2412. # useless for serving static content. So one usually enables the
  2413. # exportation for CGI and SSI requests only.
  2414. # o StrictRequire:
  2415. # This denies access when "SSLRequireSSL" or "SSLRequire" applied even
  2416. # under a "Satisfy any" situation, i.e. when it applies access is denied
  2417. # and no other module can change it.
  2418. # o OptRenegotiate:
  2419. # This enables optimized SSL connection renegotiation handling when SSL
  2420. # directives are used in per-directory context.
  2421. #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
  2422. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  2423. SSLOptions +StdEnvVars
  2424. </FilesMatch>
  2425. <Directory /usr/lib/cgi-bin>
  2426. SSLOptions +StdEnvVars
  2427. </Directory>
  2428. # SSL Protocol Adjustments:
  2429. # The safe and default but still SSL/TLS standard compliant shutdown
  2430. # approach is that mod_ssl sends the close notify alert but doesn't wait for
  2431. # the close notify alert from client. When you need a different shutdown
  2432. # approach you can use one of the following variables:
  2433. # o ssl-unclean-shutdown:
  2434. # This forces an unclean shutdown when the connection is closed, i.e. no
  2435. # SSL close notify alert is send or allowed to received. This violates
  2436. # the SSL/TLS standard but is needed for some brain-dead browsers. Use
  2437. # this when you receive I/O errors because of the standard approach where
  2438. # mod_ssl sends the close notify alert.
  2439. # o ssl-accurate-shutdown:
  2440. # This forces an accurate shutdown when the connection is closed, i.e. a
  2441. # SSL close notify alert is send and mod_ssl waits for the close notify
  2442. # alert of the client. This is 100% SSL/TLS standard compliant, but in
  2443. # practice often causes hanging connections with brain-dead browsers. Use
  2444. # this only for browsers where you know that their SSL implementation
  2445. # works correctly.
  2446. # Notice: Most problems of broken clients are also related to the HTTP
  2447. # keep-alive facility, so you usually additionally want to disable
  2448. # keep-alive for those clients, too. Use variable "nokeepalive" for this.
  2449. # Similarly, one has to force some clients to use HTTP/1.0 to workaround
  2450. # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
  2451. # "force-response-1.0" for this.
  2452. BrowserMatch "MSIE [2-6]" \
  2453. nokeepalive ssl-unclean-shutdown \
  2454. downgrade-1.0 force-response-1.0
  2455. # MSIE 7 and newer should be able to use keepalive
  2456. BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  2457. </VirtualHost>
  2458. </IfModule>
  2459. #+END_SRC
  2460. Enable your site with:
  2461. #+BEGIN_SRC: bash
  2462. a2ensite
  2463. #+END_SRC
  2464. then select the domain name and reload.
  2465. #+BEGIN_SRC: bash
  2466. service apache2 reload
  2467. #+END_SRC
  2468. and alter permissions:
  2469. #+BEGIN_SRC: bash
  2470. chmod -R 755 /var/www/$HOSTNAME/htdocs
  2471. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs
  2472. #+END_SRC
  2473. Open a browser and visit http://$HOSTNAME/install.php, then fill out the details. Once everything has been accepted without errors:
  2474. #+BEGIN_SRC: bash
  2475. rm /var/www/$HOSTNAME/htdocs/install.php
  2476. #+END_SRC
  2477. Add a few extra mime types:
  2478. #+BEGIN_SRC: bash
  2479. emacs /var/www/$HOSTNAME/htdocs/conf/mime.conf
  2480. #+END_SRC
  2481. Append the following:
  2482. #+BEGIN_SRC: bash
  2483. ogv video/ogg
  2484. mp4 video/mp4
  2485. webm video/webm
  2486. #+END_SRC
  2487. Save and exit.
  2488. 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*.
  2489. Now you can visit your wiki and begin editing.
  2490. ** Install Bitmessage
  2491. #+BEGIN_VERSE
  2492. /Love your neighbour. Fight the future. If you are reading this you ARE the resistance./
  2493. -- BitChirp
  2494. #+END_VERSE
  2495. *** A new kind of Email
  2496. [[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.
  2497. 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.
  2498. Installing Bitmessage as a daemon will increase the size of the network, and therefore the level of security for all users.
  2499. *** The Daemon
  2500. Install from the current source code.
  2501. #+BEGIN_SRC: bash
  2502. apt-get install python screen
  2503. cd /tmp
  2504. git clone https://github.com/Bitmessage/PyBitmessage.git
  2505. cd PyBitmessage
  2506. make install
  2507. #+END_SRC
  2508. Now create the daemon.
  2509. #+BEGIN_SRC: bash
  2510. emacs /etc/init.d/pybitmessage
  2511. #+END_SRC
  2512. Add the following text:
  2513. #+BEGIN_SRC: bash
  2514. #!/bin/bash
  2515. # /etc/init.d/bitmessage
  2516. ### BEGIN INIT INFO
  2517. # Provides: pybitmessage
  2518. # Required-Start: $remote_fs $syslog
  2519. # Required-Stop: $remote_fs $syslog
  2520. # Default-Start: 2 3 4 5
  2521. # Default-Stop: 0 1 6
  2522. # Short-Description: starts bitmessage as a background daemon, suitable for servers
  2523. # Description: This file should be used to construct scripts to be
  2524. # placed in /etc/init.d.
  2525. ### END INIT INFO
  2526. # Author: Super-Nathan <BM-Gu2k3Wy2hpTMYBxSoM2937SPcuU6xzEj>
  2527. #Settings
  2528. SERVICE='pybitmessage'
  2529. LOGFILE='/dev/null' # this disables logging
  2530. # LOGFILE='/var/log/bitmessage.log' # comment out the above line and un-comment this line to save a log
  2531. COMMAND="python bitmessagemain.py > $LOGFILE"
  2532. USERNAME='bitmsg'
  2533. NICELEVEL=19 # from 0-19 the bigger the number, the less the impact on system resources
  2534. HISTORY=1024
  2535. PBM_LOCATION="/usr/local/share/pybitmessage"
  2536. INVOCATION="nice -n ${NICELEVEL} ${COMMAND}"
  2537. PATH='/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl:/sbin:/usr/sbin:/bin:/usr/local/share/pybitmessage'
  2538. bm_start() {
  2539. echo "Starting $SERVICE..."
  2540. cd ${PBM_LOCATION}
  2541. su --command "screen -h ${HISTORY} -dmS ${SERVICE} ${INVOCATION}" $USERNAME
  2542. }
  2543. bm_stop() {
  2544. echo "Stopping $SERVICE"
  2545. su --command "screen -p 0 -S ${SERVICE} -X stuff "'^C'"" $USERNAME
  2546. }
  2547. #Start-Stop here
  2548. case "$1" in
  2549. start)
  2550. bm_start
  2551. ;;
  2552. stop)
  2553. bm_stop
  2554. ;;
  2555. restart)
  2556. bm_stop
  2557. sleep 60s
  2558. bm_start
  2559. ;;
  2560. *)
  2561. echo "Usage: $0 {start|stop|restart}"
  2562. exit 1
  2563. ;;
  2564. esac
  2565. exit 0
  2566. #+END_SRC
  2567. Save and exit.
  2568. 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.
  2569. #+BEGIN_SRC: bash
  2570. adduser bitmsg
  2571. #+END_SRC
  2572. Create a /keys.dat/ file which is used to configure Bitmessage.
  2573. #+BEGIN_SRC: bash
  2574. mkdir /home/bitmsg/.config
  2575. mkdir /home/bitmsg/.config/PyBitmessage
  2576. emacs /home/bitmsg/.config/PyBitmessage/keys.dat
  2577. #+END_SRC
  2578. Add the following:
  2579. #+BEGIN_SRC: bash
  2580. [bitmessagesettings]
  2581. settingsversion = 7
  2582. port = 8444
  2583. timeformat = %%a, %%d %%b %%Y %%I:%%M %%p
  2584. blackwhitelist = black
  2585. startonlogon = false
  2586. minimizetotray = false
  2587. showtraynotifications = false
  2588. startintray = false
  2589. socksproxytype = none
  2590. sockshostname = localhost
  2591. socksport = 9050
  2592. socksauthentication = false
  2593. sockslisten = false
  2594. socksusername =
  2595. sockspassword =
  2596. keysencrypted = false
  2597. messagesencrypted = false
  2598. defaultnoncetrialsperbyte = 640
  2599. defaultpayloadlengthextrabytes = 14000
  2600. minimizeonclose = false
  2601. maxacceptablenoncetrialsperbyte = 0
  2602. maxacceptablepayloadlengthextrabytes = 0
  2603. userlocale = system
  2604. namecoinrpctype = namecoind
  2605. namecoinrpchost = localhost
  2606. namecoinrpcuser =
  2607. namecoinrpcpassword =
  2608. namecoinrpcport = 8336
  2609. sendoutgoingconnections = True
  2610. daemon = true
  2611. #+END_SRC
  2612. Save and exit. Then enable the daemon and run it.
  2613. #+BEGIN_SRC: bash
  2614. rm -f /tmp/-usr-local-share-pybitmessage-*.lock
  2615. chown -R bitmsg:bitmsg /home/bitmsg
  2616. chmod +x /etc/init.d/pybitmessage
  2617. update-rc.d pybitmessage defaults
  2618. service pybitmessage start
  2619. #+END_SRC
  2620. Now open port 8444 on your internet router or firewall and direct it to the BBB.
  2621. *** Using Bitmessage
  2622. 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.
  2623. 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:
  2624. #+BEGIN_SRC: bash
  2625. cd /tmp
  2626. git clone https://github.com/Bitmessage/PyBitmessage.git
  2627. cd PyBitmessage
  2628. make install
  2629. pybitmessage
  2630. #+END_SRC
  2631. *** Connect to Email
  2632. TODO: how to connect Bitmessage to an email client.
  2633. #+BEGIN_SRC: bash
  2634. cd /tmp
  2635. wget http://freedombone.uk.to/notbit.tar.gz
  2636. #+END_SRC
  2637. Verify it.
  2638. #+BEGIN_SRC: bash
  2639. sha256sum notbit.tar.gz
  2640. 972fdc9cbb8034141282337dcd5e557bce57969ff6bd1d607da89bd93cc7bb68
  2641. #+END_SRC
  2642. Extract and install it.
  2643. #+BEGIN_SRC: bash
  2644. tar -xzvf notbit.tar.gz
  2645. cd notbit
  2646. apt-get install dh-autoreconf
  2647. ./autogen.sh --prefix=/home/myusername
  2648. make
  2649. make install
  2650. #+END_SRC
  2651. ** Overcome restrictive environments
  2652. #+BEGIN_VERSE
  2653. /Censorship reflects a society's lack of confidence in itself. It is a hallmark of an authoritarian regime./
  2654. -- Potter Stewart
  2655. #+END_VERSE
  2656. 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.
  2657. 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.
  2658. #+BEGIN_SRC: bash
  2659. apt-get install shellinabox libapache2-mod-proxy-html
  2660. #+END_SRC
  2661. Update your Apache configuration.
  2662. #+BEGIN_SRC: bash
  2663. export HOSTNAME=mydomainname.com
  2664. emacs /etc/apache2/sites-available/$HOSTNAME
  2665. #+END_SRC
  2666. Within the section which begins with *<VirtualHost *:443>* add the following, replacing /mydomainname.com/ with your domain name and /myusername/ with your username.
  2667. #+BEGIN_SRC: bash
  2668. <Location /shell>
  2669. ProxyPass http://localhost:4200/
  2670. Order allow,deny
  2671. Allow from all
  2672. AuthName "Authentication for shellinabox"
  2673. AuthUserFile /home/mydomainname.com/public_html/.htpasswd
  2674. AuthGroupFile /home/mydomainname.com/public_html/.htgroup
  2675. AuthType Basic
  2676. Require group shellinabox
  2677. Require user myusername
  2678. </Location>
  2679. #+END_SRC
  2680. 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.
  2681. #+BEGIN_SRC: bash
  2682. mkdir /home/$HOSTNAME
  2683. mkdir /home/$HOSTNAME/public_html
  2684. htpasswd -c /home/$HOSTNAME/public_html/.htpasswd myusername
  2685. #+END_SRC
  2686. Create a user group.
  2687. #+BEGIN_SRC: bash
  2688. emacs /home/$HOSTNAME/public_html/.htgroup
  2689. #+END_SRC
  2690. Add the following:
  2691. #+BEGIN_SRC: bash
  2692. shellinabox: myusername
  2693. #+END_SRC
  2694. Save and exit, then restart Apache.
  2695. #+BEGIN_SRC: bash
  2696. a2enmod proxy_http
  2697. service apache2 restart
  2698. #+END_SRC
  2699. Now with a web browser navigate to https://mydomainname.com/shell and log in.
  2700. 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/.
  2701. ** Set up a mailing list
  2702. #+BEGIN_VERSE
  2703. /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./
  2704. -- Jono Bacon
  2705. #+END_VERSE
  2706. *** With Email
  2707. 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.
  2708. **** Installation
  2709. #+BEGIN_SRC: bash
  2710. export HOSTNAME=mydomainname.com
  2711. apt-get install mailman
  2712. newlist mailman
  2713. #+END_SRC
  2714. Enter an email address for the list administrator and a password.
  2715. #+BEGIN_SRC: bash
  2716. emacs /etc/mailman/mm_cfg.py
  2717. #+END_SRC
  2718. Set *MTA=None* and change *http:* to *https:*, then save and exit.
  2719. Add some settings.
  2720. #+BEGIN_SRC: bash
  2721. emacs /etc/exim4/conf.d/main/04_mailman_options
  2722. #+END_SRC
  2723. Add the following, replacing /mydomainname.com/ with your domain name.
  2724. #+BEGIN_SRC: bash
  2725. # Mailman macro definitions
  2726. # Home dir for the Mailman installation
  2727. MM_HOME=/var/lib/mailman
  2728. # User and group for Mailman
  2729. MM_UID=list
  2730. MM_GID=list
  2731. #
  2732. # Domains that your lists are in - colon separated list
  2733. # you may wish to add these into local_domains as well
  2734. domainlist mm_domains=mydomainname.com
  2735. # The path of the Mailman mail wrapper script
  2736. MM_WRAP=MM_HOME/mail/mailman
  2737. #
  2738. # The path of the list config file (used as a required file when
  2739. # verifying list addresses)
  2740. MM_LISTCHK=MM_HOME/lists/${lc::$local_part}/config.pck
  2741. #+END_SRC
  2742. Save and exit.
  2743. #+BEGIN_SRC: bash
  2744. emacs /etc/exim4/conf.d/main/000_localmacros
  2745. #+END_SRC
  2746. Append the following:
  2747. #+BEGIN_SRC: bash
  2748. SYSTEM_ALIASES_PIPE_TRANSPORT = address_pipe
  2749. SYSTEM_ALIASES_USER = list
  2750. SYSTEM_ALIASES_GROUP = list
  2751. #+END_SRC
  2752. Save and exit.
  2753. #+BEGIN_SRC: bash
  2754. emacs /etc/exim4/conf.d/acl/30_exim4-config_check_rcpt
  2755. #+END_SRC
  2756. Append the following, before the final /accept/:
  2757. #+BEGIN_SRC: bash
  2758. # Do callback verification unless Mailman incoming bounce
  2759. deny !local_parts = *-bounces : *-bounces+*
  2760. !verify = sender/callout=30s,defer_ok
  2761. #+END_SRC
  2762. Save and exit.
  2763. #+BEGIN_SRC: bash
  2764. emacs
  2765. /etc/exim4/conf.d/router/450_mailman_aliases
  2766. #+END_SRC
  2767. Add the following:
  2768. #+BEGIN_SRC: bash
  2769. mailman_router:
  2770. driver = accept
  2771. domains = +mm_domains
  2772. require_files = MM_LISTCHK
  2773. local_part_suffix_optional
  2774. local_part_suffix = -admin : \
  2775. -bounces : -bounces+* : \
  2776. -confirm : -confirm+* : \
  2777. -join : -leave : \
  2778. -owner : -request : \
  2779. -subscribe : -unsubscribe
  2780. transport = mailman_transport
  2781. #+END_SRC
  2782. Save and exit.
  2783. #+BEGIN_SRC: bash
  2784. emacs /etc/exim4/conf.d/transport/40_mailman_pipe
  2785. #+END_SRC
  2786. Add the following:
  2787. #+BEGIN_SRC: bash
  2788. mailman_transport:
  2789. driver = pipe
  2790. command = MM_WRAP \
  2791. '${if def:local_part_suffix \
  2792. {${sg{$local_part_suffix}{-(\\w+)(\\+.*)?}{\$1}}} \
  2793. {post}}' \
  2794. $local_part
  2795. current_directory = MM_HOME
  2796. home_directory = MM_HOME
  2797. user = MM_UID
  2798. group = MM_GID
  2799. #+END_SRC
  2800. Save and exit.
  2801. #+BEGIN_SRC: bash
  2802. chown root:list /var/lib/mailman/mail/mailman
  2803. update-exim4.conf.template -r
  2804. update-exim4.conf
  2805. service exim4 restart
  2806. emacs /etc/apache2/conf.d/mailman
  2807. #+END_SRC
  2808. Add the following:
  2809. #+BEGIN_SRC: bash
  2810. Alias /pipermail /var/lib/mailman/archives/public
  2811. Alias /images/mailman /usr/share/images/mailman
  2812. <directory /var/lib/mailman/archives/public>
  2813. DirectoryIndex index.html
  2814. </directory>
  2815. #+END_SRC
  2816. Save and exit.
  2817. #+BEGIN_SRC: bash
  2818. emacs /etc/apache2/sites-available/$HOSTNAME
  2819. #+END_SRC
  2820. Add the following to the 443 section.
  2821. #+BEGIN_SRC: bash
  2822. <Location /mailman>
  2823. Options Indexes FollowSymLinks MultiViews
  2824. Order allow,deny
  2825. Allow from all
  2826. RedirectMatch ^/$ /cgi-bin/mailman/listinfo
  2827. </Location>
  2828. #+END_SRC
  2829. Save and exit.
  2830. #+BEGIN_SRC: bash
  2831. service apache2 restart
  2832. #+END_SRC
  2833. Now add your mailing list. The list name should not include any spaces.
  2834. #+BEGIN_SRC: bash
  2835. newlist mymailinglistname
  2836. #+END_SRC
  2837. With a browser visit https://$HOSTNAME/cgi-bin/mailman/admin/mymailinglistname to configure the mailing list.
  2838. Under *General Options* add an email address for a moderator (could be the same as the administrator) and click *Submit your changes*.
  2839. Under *Privacy Options* set steps required for subscription to *Confirm and approve* and click *Submit your changes*.
  2840. Also change these settings for the account within https://$HOSTNAME/cgi-bin/mailman/admin/mailman
  2841. #+BEGIN_SRC: bash
  2842. emacs /etc/aliases
  2843. #+END_SRC
  2844. Append the following, replacing /mymailinglistname/ with your mailing list name:
  2845. #+BEGIN_SRC: bash
  2846. mymailinglistname: "|/var/lib/mailman/mail/mailman post mymailinglistname"
  2847. mymailinglistname-admin: "|/var/lib/mailman/mail/mailman admin mymailinglistname"
  2848. mymailinglistname-bounces: "|/var/lib/mailman/mail/mailman bounces mymailinglistname"
  2849. mymailinglistname-confirm: "|/var/lib/mailman/mail/mailman confirm mymailinglistname"
  2850. mymailinglistname-join: "|/var/lib/mailman/mail/mailman join mymailinglistname"
  2851. mymailinglistname-leave: "|/var/lib/mailman/mail/mailman leave mymailinglistname"
  2852. mymailinglistname-owner: "|/var/lib/mailman/mail/mailman owner mymailinglistname"
  2853. mymailinglistname-request: "|/var/lib/mailman/mail/mailman request mymailinglistname"
  2854. mymailinglistname-subscribe: "|/var/lib/mailman/mail/mailman subscribe mymailinglistname"
  2855. mymailinglistname-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mymailinglistname"
  2856. #+END_SRC
  2857. Save and exit. Then to test that the mailing list works:
  2858. #+BEGIN_SRC: bash
  2859. exim -d+route -bt mymailinglistname@$HOSTNAME
  2860. #+END_SRC
  2861. If everything is working then this shouldn't show any problems.
  2862. **** Using the mailing list
  2863. Direct subscribers towards:
  2864. #+BEGIN_SRC: bash
  2865. https://mydomainname.com/cgi-bin/mailman/listinfo/mymailinglistname
  2866. #+END_SRC
  2867. To administrate the list visit:
  2868. #+BEGIN_SRC: bash
  2869. https://mydomainname.com/cgi-bin/mailman/admin/mymailinglistname
  2870. #+END_SRC
  2871. To add another mailing list:
  2872. #+BEGIN_SRC: bash
  2873. newlist mymailinglistname
  2874. #+END_SRC
  2875. To delete a mailing list:
  2876. #+BEGIN_SRC: bash
  2877. rmlist -a mymailinglistname
  2878. #+END_SRC
  2879. *** With Bitmessage
  2880. 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".
  2881. On a Debian based system:
  2882. #+BEGIN_SRC: bash
  2883. sudo apt-get install makepasswd
  2884. #+END_SRC
  2885. or on an RPM based system:
  2886. #+BEGIN_SRC: bash
  2887. sudo yum install makepasswd
  2888. #+END_SRC
  2889. Create a name for your mailing list. This will be a random string.
  2890. #+BEGIN_SRC: bash
  2891. makepasswd -c 40
  2892. #+END_SRC
  2893. Keep a note of this.
  2894. Run the Bitmessage client and on the menu select *File/Join-Create Chan/Create new chan*
  2895. 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.
  2896. 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.
  2897. 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.
  2898. 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.
  2899. ** Install Tripwire
  2900. #+BEGIN_VERSE
  2901. /...by the time you get done with all of that, we have a freedom box/
  2902. -- Eben Moglen
  2903. #+END_VERSE
  2904. 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.
  2905. #+BEGIN_SRC: bash
  2906. apt-get install tripwire
  2907. export HOSTNAME=mydomainname.com
  2908. cd /etc/tripwire
  2909. cp arm-local.key $HOSTNAME-local.key
  2910. cp site.key $HOSTNAME-site.key
  2911. tripwire --init
  2912. tripwire --update-policy --secure-mode low /etc/tripwire/twpol.txt
  2913. tripwire --check --interactive
  2914. #+END_SRC
  2915. you will be asked for two passphrases ("site" and "local"). Make a note of these.
  2916. Turn off reporting of changes to system logs.
  2917. #+BEGIN_SRC: bash
  2918. emacs /etc/tripwire/twcfg.txt
  2919. #+END_SRC
  2920. Set *SYSLOGREPORTING* to false and comment out the line, then save and exit.
  2921. #+BEGIN_SRC: bash
  2922. emacs /etc/tripwire/twpol.txt
  2923. #+END_SRC
  2924. Comment out the line:
  2925. #+BEGIN_SRC: bash
  2926. /var/log -> $(SEC_CONFIG) ;
  2927. #+END_SRC
  2928. Then save and exit.
  2929. If you subsequently install any more packages or make configuration changes then update the policy again with:
  2930. #+BEGIN_SRC: bash
  2931. tripwire --update-policy --secure-mode low /etc/tripwire/twpol.txt
  2932. #+END_SRC
  2933. Also, to look for any rootkits.
  2934. #+BEGIN_SRC: bash
  2935. apt-get install rkhunter
  2936. #+END_SRC
  2937. * Router/Firewall ports
  2938. The following ports on your internet router/firewall should be forwarded to the BBB.
  2939. | Protocol | Port/s |
  2940. |---------------+------------|
  2941. | Gopher | 70 |
  2942. | HTTP | 80 |
  2943. | HTTPS | 443 |
  2944. | IMAP | 143 |
  2945. | IRC SSL | 6670 |
  2946. | SIP | 5060..5061 |
  2947. | SMTP | 25 |
  2948. | SMTPS | 465 |
  2949. | SSH | 22 |
  2950. | XMPP | 5222..5223 |
  2951. | XMPP (server) | 5269 |
  2952. | XMPP (BOSH) | 5280..5281 |
  2953. | Bitmessage | 8444 |
  2954. * Hints and Tips
  2955. ** Messaging security
  2956. 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.
  2957. ** Moving Domains
  2958. 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:
  2959. #+BEGIN_SRC: bash
  2960. find /var/www/mynewdomain/htdocs -type f -exec sed -i 's@myolddomain@mynewdomain@g' {} \;
  2961. #+END_SRC
  2962. If you're moving the blog to a new domain then you will need to delete the lock file:
  2963. #+BEGIN_SRC: bash
  2964. rm /var/www/myblogdomainname.com/htdocs/fp-content/%%setup.lock
  2965. #+END_SRC
  2966. 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.
  2967. ** MySql foo
  2968. *** Backup all databases
  2969. To back up all mysql databases:
  2970. #+BEGIN_SRC: bash
  2971. mysqldump -u root -p --all-databases --events > /var/backups/databasebackup.sql
  2972. #+END_SRC
  2973. *** Restoring a particular mysql database
  2974. To restore yesterday's friendica backup:
  2975. #+BEGIN_SRC: bash
  2976. mysql -D friendica -o < /var/backups/friendica_daily.sql
  2977. #+END_SRC
  2978. To restore yesterday's mediawiki backup:
  2979. #+BEGIN_SRC: bash
  2980. mysql -D wikidb -o < /var/backups/wikidb_daily.sql
  2981. #+END_SRC
  2982. *** Removing mysql server
  2983. If you manage to screw up sql server completely then it can be fully deleted with:
  2984. #+BEGIN_SRC: bash
  2985. ps aux | grep mysql
  2986. #+END_SRC
  2987. and use /kill -9 <pid>/ to kill all mysql processes.
  2988. #+BEGIN_SRC: bash
  2989. apt-get remove --purge mysql\*
  2990. apt-get clean
  2991. updatedb
  2992. #+END_SRC
  2993. * Deprecated
  2994. The following items have been deprecated until such time as a successful installation is achieved.
  2995. ** Collaborative Document Editing
  2996. #+BEGIN_VERSE
  2997. /Openness and participation are antidotes to surveillance and control./
  2998. -- Howard Rheingold
  2999. #+END_VERSE
  3000. #+BEGIN_SRC: bash
  3001. apt-get install nodejs-legacy
  3002. curl https://npmjs.org/install.sh | sh
  3003. #+END_SRC
  3004. Create an etherpad database.
  3005. #+BEGIN_SRC: bash
  3006. mysql -p
  3007. CREATE DATABASE etherpad CHARACTER SET utf8 COLLATE utf8_general_ci;
  3008. GRANT ALL PRIVILEGES ON etherpad.* TO etherpad@localhost IDENTIFIED BY '__yourPasswd__';
  3009. FLUSH PRIVILEGES;
  3010. exit
  3011. #+END_SRC
  3012. Download etherpad.
  3013. #+BEGIN_SRC: bash
  3014. export HOSTNAME=mydomainname.com
  3015. cd /var/www/$HOSTNAME/htdocs
  3016. git clone git://github.com/ether/etherpad-lite.git etherpad
  3017. #+END_SRC
  3018. Edit the configuration file
  3019. #+BEGIN_SRC: bash
  3020. cd /var/www/$HOSTNAME/htdocs/etherpad
  3021. cp settings.json.template settings.json
  3022. emacs /var/www/$HOSTNAME/htdocs/etherpad/settings.json
  3023. #+END_SRC
  3024. Change the following settings. /rAnD0m5tRIng/ should be altered to a random string 10 characters in length.
  3025. #+BEGIN_SRC: bash
  3026. //IP and port which etherpad should bind at
  3027. "ip": "127.0.0.1",
  3028. // set a session key
  3029. "sessionKey" : "rAnD0m5tRIng",
  3030. //configure the connection settings
  3031. "dbType" : "mysql",
  3032. "dbSettings" : {
  3033. "user" : "etherpad",
  3034. "host" : "localhost",
  3035. "password": "__yourPassword__",
  3036. "database": "etherpad"
  3037. },
  3038. // add admin user
  3039. "users": {
  3040. "admin": {
  3041. "password": "__yourAdminPassword__",
  3042. "is_admin": true
  3043. }
  3044. },
  3045. #+END_SRC
  3046. Save and exit, then create a system user.
  3047. #+BEGIN_SRC: bash
  3048. adduser --system --home=/var/www/$HOSTNAME/htdocs/etherpad/ --group etherpad
  3049. chown -R etherpad: /var/www/$HOSTNAME/htdocs/etherpad/
  3050. #+END_SRC
  3051. Create an init script using your favorite editor.
  3052. #+BEGIN_SRC: bash
  3053. emacs /etc/init.d/etherpad
  3054. #+END_SRC
  3055. Add the following, replacing /mydomainname.com/ with your domain name:
  3056. #+BEGIN_SRC: bash
  3057. #!/bin/sh
  3058. ### BEGIN INIT INFO
  3059. # Provides: etherpad-lite
  3060. # Required-Start: $local_fs $remote_fs $network $syslog
  3061. # Required-Stop: $local_fs $remote_fs $network $syslog
  3062. # Default-Start: 2 3 4 5
  3063. # Default-Stop: 0 1 6
  3064. # Short-Description: starts etherpad lite
  3065. # Description: starts etherpad lite using start-stop-daemon
  3066. ### END INIT INFO
  3067. PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin"
  3068. LOGFILE="/var/www/mydomainname.com/htdocs/etherpad/etherpad-lite.log"
  3069. EPLITE_DIR="/var/www/mydomainname.com/htdocs/etherpad"
  3070. EPLITE_BIN="bin/safeRun.sh"
  3071. USER="etherpad"
  3072. GROUP="etherpad"
  3073. DESC="Etherpad Lite"
  3074. NAME="etherpad-lite"
  3075. set -e
  3076. . /lib/lsb/init-functions
  3077. start() {
  3078. echo "Starting $DESC... "
  3079. start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile /var/run/$NAME.pid --exec $EPLITE_DIR/$EPLITE_BIN -- $LOGFILE || true
  3080. echo "done"
  3081. }
  3082. #We need this function to ensure the whole process tree will be killed
  3083. killtree() {
  3084. local _pid=$1
  3085. local _sig=${2-TERM}
  3086. for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
  3087. killtree ${_child} ${_sig}
  3088. done
  3089. kill -${_sig} ${_pid}
  3090. }
  3091. stop() {
  3092. echo "Stopping $DESC... "
  3093. while test -d /proc/$(cat /var/run/$NAME.pid); do
  3094. killtree $(cat /var/run/$NAME.pid) 15
  3095. sleep 0.5
  3096. done
  3097. rm /var/run/$NAME.pid
  3098. echo "done"
  3099. }
  3100. status() {
  3101. status_of_proc -p /var/run/$NAME.pid "" "etherpad-lite" && exit 0 || exit $?
  3102. }
  3103. case "$1" in
  3104. start)
  3105. start
  3106. ;;
  3107. stop)
  3108. stop
  3109. ;;
  3110. restart)
  3111. stop
  3112. start
  3113. ;;
  3114. status)
  3115. status
  3116. ;;
  3117. *)
  3118. echo "Usage: $NAME {start|stop|restart|status}" >&2
  3119. exit 1
  3120. ;;
  3121. esac
  3122. exit 0
  3123. #+END_SRC
  3124. Save and exit, then enable the daemon.
  3125. #+BEGIN_SRC: bash
  3126. chmod +x /etc/init.d/etherpad
  3127. update-rc.d etherpad defaults
  3128. service etherpad start
  3129. #+END_SRC
  3130. Update your Apache configuration.
  3131. #+BEGIN_SRC: bash
  3132. emacs /etc/apache2/sites-available/$HOSTNAME
  3133. #+END_SRC
  3134. Within the section which begins with *<VirtualHost *:443>* add the following:
  3135. #+BEGIN_SRC: bash
  3136. <Location /etherpad>
  3137. ProxyPass http://localhost:9001/
  3138. ProxyPassReverse http://localhost:9001/
  3139. Order allow,deny
  3140. allow from all
  3141. AuthName "Welcome to Etherpad"
  3142. AuthUserFile /home/mydomainname.com/public_html/.htpasswd
  3143. AuthGroupFile /home/mydomainname.com/public_html/.htgroup
  3144. AuthType Basic
  3145. Require group etherpad
  3146. </Location>
  3147. #+END_SRC
  3148. Save and exit, then restart Apache.
  3149. #+BEGIN_SRC: bash
  3150. apt-get install libapache2-mod-proxy-html
  3151. a2enmod proxy proxy_http headers deflate
  3152. service apache2 restart
  3153. #+END_SRC
  3154. Create some passwords for users.
  3155. #+BEGIN_SRC: bash
  3156. mkdir /home/$HOSTNAME
  3157. mkdir /home/$HOSTNAME/public_html
  3158. htpasswd -c /home/$HOSTNAME/public_html/.htpasswd myusername
  3159. #+END_SRC
  3160. Create a user group.
  3161. #+BEGIN_SRC: bash
  3162. emacs /home/$HOSTNAME/public_html/.htgroup
  3163. #+END_SRC
  3164. Add the following:
  3165. #+BEGIN_SRC: bash
  3166. etherpad: myusername
  3167. #+END_SRC
  3168. Save and exit.
  3169. ** Install a VoIP server
  3170. #+BEGIN_VERSE
  3171. /Our core principles, whether in software or sovereignty, have always been about freedom and dignity, for all people, on an equal basis/
  3172. -- David Sugar, GNU Telephony
  3173. #+END_VERSE
  3174. *** The server
  3175. 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.
  3176. Edit your package sources:
  3177. #+BEGIN_SRC: bash
  3178. emacs /etc/apt/sources.list
  3179. #+END_SRC
  3180. Append the following line:
  3181. #+BEGIN_SRC: bash
  3182. deb http://dev.gnutelephony.org/archive/ wheezy/
  3183. #+END_SRC
  3184. Save and exit.
  3185. 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
  3186. #+BEGIN_SRC: bash
  3187. apt-get install gnutelephony-keyring
  3188. #+END_SRC
  3189. After that it will be happy to accept it as a signed repository. The verification keys can also be directly fetched with
  3190. #+BEGIN_SRC: bash
  3191. cd /tmp
  3192. wget http://dev.gnutelephony.org/archive/wheezy/public.key
  3193. #+END_SRC
  3194. and manually added instead with
  3195. #+BEGIN_SRC: bash
  3196. apt-key add public.key
  3197. #+END_SRC
  3198. To make sure you have all dependencies, do
  3199. #+BEGIN_SRC: bash
  3200. apt-get update;apt-get dist-upgrade
  3201. #+END_SRC
  3202. Before we install anything, let's inspect what is available to us by using
  3203. #+BEGIN_SRC: bash
  3204. dpkg -l sipwitch
  3205. #+END_SRC
  3206. To see the main application. The columns will indicate if the package is installed, which version and a description of the package. Then do
  3207. #+BEGIN_SRC: bash
  3208. dpkg -l sipwitch-*
  3209. #+END_SRC
  3210. 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.
  3211. To install only the main application, do
  3212. #+BEGIN_SRC: bash
  3213. apt-get install sipwitch
  3214. #+END_SRC
  3215. and to install all supporting plugins:
  3216. #+BEGIN_SRC: bash
  3217. apt-get install sipwitch-plugin-scripting sipwitch-plugin-subscriber sipwitch-plugin-forward sipwitch-plugin-zeroconf
  3218. #+END_SRC
  3219. Add your user into the sipwitch group
  3220. #+BEGIN_SRC: bash
  3221. groupadd sipwitch
  3222. groupadd sipusers
  3223. usermod -aG sipwitch myusername
  3224. usermod -aG sipusers myusername
  3225. #+END_SRC
  3226. Then edit the configuration
  3227. #+BEGIN_SRC: bash
  3228. emacs /etc/sipwitch.conf
  3229. #+END_SRC
  3230. Change the *mapped* value from 200 to 20, since we don't want to be serving huge numbers of calls.
  3231. 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.
  3232. Do not set the *realm* value, as doing so seems to prevent the server from working.
  3233. Save and exit.
  3234. Create a digest string for your username:
  3235. #+BEGIN_SRC: bash
  3236. sipwitch digest myusername
  3237. #+END_SRC
  3238. Make a note of the resulting string because you're going to use it in the users file you'll now create.
  3239. #+BEGIN_SRC: bash
  3240. export HOSTNAME=mydomainname.com
  3241. touch /etc/sipwitch.d/$HOSTNAME.xml
  3242. chmod 600 /etc/sipwitch.d/$HOSTNAME.xml
  3243. emacs /etc/sipwitch.d/$HOSTNAME.xml
  3244. #+END_SRC
  3245. It should look something like the following:
  3246. #+BEGIN_SRC: bash
  3247. <provision>
  3248. <user id="myusername">
  3249. <digest>yourdigeststring</digest>
  3250. <extension>201</extension>
  3251. <display>Your full name</display>
  3252. </user>
  3253. </provision>
  3254. #+END_SRC
  3255. Save and exit. Now edit the configuration.
  3256. #+BEGIN_SRC: bash
  3257. emacs /etc/default/sipwitch
  3258. #+END_SRC
  3259. Change "desktop" to "server", then save and exit.
  3260. Update the IP settings:
  3261. #+BEGIN_SRC: bash
  3262. iptables -A INPUT -p tcp --dport 5060 -j ACCEPT
  3263. iptables -A INPUT -p udp --dport 5060 -j ACCEPT
  3264. iptables -A INPUT -p tcp --dport 5061 -j ACCEPT
  3265. iptables -A INPUT -p udp --dport 5061 -j ACCEPT
  3266. iptables-save
  3267. #+END_SRC
  3268. Test that it's working:
  3269. #+BEGIN_SRC: bash
  3270. pkill -9 sipw
  3271. sipw -x9 -f
  3272. #+END_SRC
  3273. 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.
  3274. #+BEGIN_SRC: bash
  3275. service sipwitch start
  3276. #+END_SRC
  3277. *** Clients
  3278. **** Jitsi
  3279. Download the latst version from https://jitsi.org/index.php/Main/Download
  3280. TODO
  3281. **** Twinkle client
  3282. The client should have a user profile as following:
  3283. The "user name" is the xxx id used in the <user id="xxx"> entry of /etc/sipwitch.conf
  3284. The "domain" is the yyy domain in the main config <stack><domain>yyy entry of /etc/sipwitch.conf
  3285. The SIP Authentication should have:
  3286. realm = realm as set in <registry><realm> of /etc/sipwitch.conf
  3287. authentication name = <user id="xx"> entry, same as "User Name" field.
  3288. password = value of <secret>zzz in <user> entry of /etc/sipwitch.conf
  3289. Under security tab, set "Enable ZRTP/SRTP encryption"
  3290. **** Android
  3291. TODO
  3292. CSipSimple?
  3293. ** Install Mediagoblin
  3294. #+BEGIN_SRC: bash
  3295. apt-get install git-core python python-dev python-lxml python-imaging python-virtualenv apache2-suexec libapache2-mod-fcgid
  3296. #+END_SRC
  3297. #+BEGIN_SRC: bash
  3298. adduser --system mediagoblin
  3299. addgroup mediagoblin
  3300. adduser mediagoblin mediagoblin
  3301. export HOSTNAME=mydomainname.com
  3302. cd /var/www/$HOSTNAME/htdocs
  3303. git clone git://gitorious.org/mediagoblin/mediagoblin.git mediagoblin
  3304. chown -hR mediagoblin:mediagoblin /var/www/$HOSTNAME/htdocs/mediagoblin
  3305. cd /var/www/$HOSTNAME/htdocs/mediagoblin
  3306. git submodule init && git submodule update
  3307. cp mediagoblin.ini mediagoblin_local.ini
  3308. emacs mediagoblin.ini
  3309. #+END_SRC
  3310. Set email_sender_address to the address you wish to be used as the sender for system-generated emails
  3311. Edit direct_remote_path, base_dir, and base_url if your mediagoblin directory is not the root directory of your vhost.
  3312. Save and exit.
  3313. #+BEGIN_SRC: bash
  3314. a2enmod suexec
  3315. a2enmod fcgid
  3316. emacs /etc/apache2/sites-available/$HOSTNAME
  3317. #+END_SRC
  3318. Add the following to the 80 virtual host, replacing mydomainname.com with your domain name.
  3319. #+BEGIN_SRC: bash
  3320. <Directory /var/www/mydomainname.com/htdocs/mediagoblin>
  3321. deny from all
  3322. </Directory>
  3323. #+END_SRC
  3324. Add the following to the 443 virtual host.
  3325. #+BEGIN_SRC: bash
  3326. # Serve static and media files via alias
  3327. Alias /mgoblin_static/ /var/www/mydomainname.com/htdocs/mediagoblin/mediagoblin/static/
  3328. Alias /mgoblin_media/ /var/www/mydomainname.com/htdocs/mediagoblin/user_dev/media/public/
  3329. # Rewrite all URLs to fcgi, except for static and media urls
  3330. RewriteEngine On
  3331. RewriteRule ^(mgoblin_static|mgoblin_media)($|/) - [L]
  3332. RewriteCond %{REQUEST_FILENAME} !-f
  3333. RewriteRule ^/(.*)$ /mg.fcgi/$1 [QSA,L]
  3334. # Allow access to static and media directories
  3335. <Directory /var/www/mydomainname.com/htdocs/mediagoblin/mediagoblin/static>
  3336. Order allow,deny
  3337. Allow from all
  3338. </Directory>
  3339. <Directory /var/www/mydomainname.com/htdocs/mediagoblin/mediagoblin/user_dev/media/public>
  3340. Order allow,deny
  3341. Allow from all
  3342. </Directory>
  3343. # Connect to fcgi server
  3344. FastCGIExternalServer /var/www/mg.fcgi -host 127.0.0.1:26543
  3345. #+END_SRC
  3346. Save and exit
  3347. #+BEGIN_SRC: bash
  3348. cd /var/www/$HOSTNAME/htdocs/mediagoblin
  3349. ./lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543
  3350. #+END_SRC
  3351. https://github.com/joar/mediagoblin-init-scripts
  3352. ** Kune
  3353. 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).
  3354. #+BEGIN_SRC: bash
  3355. apt-get install openjdk-6-jdk openjdk-7-jre mysql-server adduser dbconfig-common libjmagick6-jni
  3356. #+END_SRC
  3357. Add the Kune repository:
  3358. #+BEGIN_SRC: bash
  3359. emacs /etc/apt/sources.list
  3360. #+END_SRC
  3361. Append the following:
  3362. #+BEGIN_SRC: bash
  3363. deb ftp://ftp.kune.ourproject.org/pub/kune/debian/ stable/
  3364. #+END_SRC
  3365. Save and exit, then install the Kune package.
  3366. #+BEGIN_SRC: bash
  3367. gpg --keyserver pgp.mit.edu --recv-keys 9E358A05
  3368. gpg --armor --export 9E358A05 | apt-key add -
  3369. apt-get update
  3370. apt-get install kune
  3371. #+END_SRC
  3372. You will be asked for the MySql root password and another password to be used with the Kune database.
  3373. Allow the system to start automatically at boot.
  3374. #+BEGIN_SRC: bash
  3375. emacs /etc/default/kune
  3376. #+END_SRC
  3377. Set /START=yes/, then save and exit.
  3378. #+BEGIN_SRC: bash
  3379. service kune start
  3380. #+END_SRC
  3381. Now configure Apache.
  3382. #+BEGIN_SRC: bash
  3383. a2enmod expires
  3384. a2enmod proxy
  3385. a2enmod proxy_connect
  3386. a2enmod proxy_http
  3387. #+END_SRC
  3388. Upgrade the database.
  3389. #+BEGIN_SRC: bash
  3390. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.1.0+b5
  3391. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.1.0+b6
  3392. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.2.0+b12
  3393. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.2.0+b23
  3394. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.2.0+b25
  3395. #+END_SRC
  3396. Edit the Apache configuration.
  3397. #+BEGIN_SRC: bash
  3398. emacs /etc/apache2/sites-available/$HOSTNAME
  3399. #+END_SRC
  3400. <VirtualHost *:80>
  3401. ServerName YOURSERVERNAME
  3402. ProxyRequests Off
  3403. <Proxy *>
  3404. Order deny,allow
  3405. Allow from all
  3406. </Proxy>
  3407. <Files *.cache.*>
  3408. ExpiresActive On
  3409. ExpiresDefault "modification plus 2 years"
  3410. </Files>
  3411. <Files *.nocache.*>
  3412. ExpiresActive Off
  3413. </Files>
  3414. ProxyPass /kune/ http://localhost:8888/
  3415. ProxyPassReverse /kune/ http://localhost:8888/
  3416. <Location /var/www/mydomainname.com/htdocs/kune/>
  3417. Order allow,deny
  3418. Allow from all
  3419. </Location>
  3420. </VirtualHost>
  3421. Within a browser open https://mydomainname.com:8888
  3422. See documentation in /usr/share/doc/kune/INSTALL.gz
  3423. * Related projects
  3424. * [[https://freedomboxfoundation.org/][Freedombox]]
  3425. * [[https://arkos.io/][ArkOS]]