beaglebone.txt 147KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621
  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. *** Webmail
  1276. #+BEGIN_VERSE
  1277. /Most of the information extracted is "content", such as recordings of phone calls or the substance of email messages./
  1278. -- From a 2013 Guardian article on GCHQ/NSA bulk internet data interception.
  1279. #+END_VERSE
  1280. 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.
  1281. Install dependencies.
  1282. #+BEGIN_SRC: bash
  1283. apt-get install libapache2-mod-authz-unixgroup
  1284. #+END_SRC
  1285. Create a mysql database, specifying a password which should be a long random string generated with a password manager such as KeepassX.
  1286. #+BEGIN_SRC: bash
  1287. mysql -u root -p
  1288. create database roundcubemail;
  1289. CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'roundcubepassword';
  1290. GRANT ALL PRIVILEGES ON roundcubemail.* TO 'roundcube'@'localhost';
  1291. quit
  1292. #+END_SRC
  1293. Download roundcube.
  1294. #+BEGIN_SRC: bash
  1295. cd /tmp
  1296. wget http://freedombone.uk.to/roundcubemail.tar.gz
  1297. #+END_SRC
  1298. Verify it.
  1299. #+BEGIN_SRC: bash
  1300. sha256sum roundcubemail.tar.gz
  1301. e8a311b22a8e1f70abb72ed9551cc9233cf6c5221f1eebf1ae64974117e3148b roundcubemail.tar.gz
  1302. #+END_SRC
  1303. Extract the files.
  1304. #+BEGIN_SRC: bash
  1305. tar -xzvf roundcubemail.tar.gz
  1306. export HOSTNAME=mydomainname.com
  1307. cp -r roundcubemail-* /var/www/$HOSTNAME/htdocs/mail
  1308. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/mail/temp
  1309. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/mail/logs
  1310. rm /var/www/$HOSTNAME/htdocs/mail/.htaccess
  1311. #+END_SRC
  1312. Edit your web site configuration.
  1313. #+BEGIN_SRC: bash
  1314. emacs /etc/apache2/sites-available/$HOSTNAME
  1315. #+END_SRC
  1316. Within the 80 VirtualHost section add the following:
  1317. #+BEGIN_SRC: bash
  1318. <Directory /var/www/mydomainname.com/htdocs/mail>
  1319. deny from all
  1320. </Directory>
  1321. #+END_SRC
  1322. Within the 443 VirtualHost section add the following:
  1323. #+BEGIN_SRC: bash
  1324. <Directory /var/www/mydomainname.com/htdocs/mail>
  1325. Options Indexes FollowSymLinks MultiViews
  1326. AllowOverride All
  1327. Order allow,deny
  1328. allow from all
  1329. </Directory>
  1330. #+END_SRC
  1331. Save and exit, then restart Apache.
  1332. #+BEGIN_SRC: bash
  1333. service apache2 restart
  1334. #+END_SRC
  1335. Now with a browser visit https://mydomainname.com/mail/installer. Scroll down and click "next". Give your webmail site a product name.
  1336. The *spellcheck_engine* option being limited to Google is slightly concerning in terms of privacy and security, but seems not to be implemented.
  1337. Change the *database password* to the password you gave when creating the MySql database above.
  1338. Set *smtp_port* to 465.
  1339. Click *create config*
  1340. Click download to download the file.
  1341. In a terminal on your local machine (not logged into the BBB):
  1342. #+BEGIN_SRC: bash
  1343. cd ~/Downloads
  1344. scp config.inc.php myusername@mydomainname.com:/home/myusername
  1345. #+END_SRC
  1346. Then in a terminal ssh'd into the BBB:
  1347. #+BEGIN_SRC: bash
  1348. mv /home/myusername/config.inc.php /var/www/$HOSTNAME/htdocs/mail/config
  1349. chmod 755 /var/www/$HOSTNAME/htdocs/mail/config/config.inc.php
  1350. #+END_SRC
  1351. Click *continue*.
  1352. Click *initialize database*.
  1353. Under *Test SMTP config* you can use a [[mailinator.com]] address to check that mail can be sent.
  1354. Now we can delete the installer.
  1355. #+BEGIN_SRC: bash
  1356. rm -rf /var/www/$HOSTNAME/htdocs/mail/installer
  1357. #+END_SRC
  1358. Now with a browser navigate to https://mydomainname.com/mail and log in.
  1359. 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.
  1360. 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.
  1361. *** Thunderbird
  1362. #+BEGIN_VERSE
  1363. /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./
  1364. -- Brian Spector, on the shutting down of the PrivateSky encrypted email service
  1365. #+END_VERSE
  1366. 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.
  1367. The following instructions should be carried out on the client machines (laptop, etc), not on the BBB itself.
  1368. **** Initial setup
  1369. Install *Thunderbird* and *Enigmail*. How you do this just depends upon your distro and software manager or "app store".
  1370. Open Thinderbird
  1371. Select "*Skip this and use existing email*"
  1372. Enter your name, email address (myusername@mydomainname.com) and the password for your user (the one from [[Add a user]]).
  1373. You'll get a message saying "/Thunderbird failed to find the settings/"
  1374. The settings should be as follows, substituting /mydomainname.com/ for your domain name and /myusername/ for the username given previously in [[Add a user]].
  1375. * Incoming: IMAP, mydomainname.com, 993, SSL/TLS, Normal Password
  1376. * Outgoing: SMTP, mydomainname.com, 465, SSL/TLS, Normal Password
  1377. * Username: myusername
  1378. Click *Done*.
  1379. Click *Get Certificate* and make sure "*permanently store this exception*" is selected", then click *Store Security Exception*.
  1380. 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.
  1381. Select "*Yes, I want to sign all of my email*"
  1382. Select "*No, I will create per-recipient rules*"
  1383. Select "*yes*" to change default settings.
  1384. **** If you have existing GPG key
  1385. Export your GPG public and private keys.
  1386. #+BEGIN_SRC: bash
  1387. gpg --output ~/public_key.txt --armor --export KEY_ID
  1388. gpg --output ~/private_key.txt --armor --export-secret-key KEY_ID
  1389. #+END_SRC
  1390. Select "*I have existing public and private keys*".
  1391. Select your public and private GPG exported key files.
  1392. Select the account which you want to use and click *Next*, *Next* and *Finish*.
  1393. Remove your exported key files.
  1394. #+BEGIN_SRC: bash
  1395. shred -zu ~/public_key.txt
  1396. shred -zu ~/private_key.txt
  1397. #+END_SRC
  1398. **** If you don't have any existing GPG or PGP key
  1399. Select "*I want to create a new key pair*"
  1400. Enter a passphrase and click *Next* a couple of times.
  1401. Click *Generate Certificate* to generate a revocation certificate.
  1402. Enter the passphrase which you gave previously.
  1403. Click *Finish*
  1404. 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.
  1405. 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.
  1406. **** Using for the first time
  1407. Click on the Thunderbird menu, which looks like three horizontal bars on the right hand side.
  1408. Hover over *preferences* and then *Account settings*.
  1409. Select *Synchronization & Storage*.
  1410. Make sure that *Keep messages for this account on this computer* is unticked, then click *Ok*.
  1411. Click on *Inbox*. Depending upon how much email you have it may take a while to import the subject lines.
  1412. Note that when sending an email for the first time you will also need to accept the SSL certificate.
  1413. 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.
  1414. **** Making folders visible
  1415. 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:
  1416. *Menu*, hover over *Preferences*, select *Account Settings*, select *Server Settings* then click on the *Advanced* button.
  1417. 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.
  1418. ** Install a Blog
  1419. #+BEGIN_VERSE
  1420. /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./
  1421. -- Nick Cohen
  1422. #+END_VERSE
  1423. 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.
  1424. 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.
  1425. Download flatpress.
  1426. #+BEGIN_SRC: bash
  1427. cd /tmp
  1428. wget http://freedombone.uk.to/flatpress.tar.gz
  1429. #+END_SRC
  1430. Verify the download:
  1431. #+BEGIN_SRC: bash
  1432. sha256sum flatpress.tar.gz
  1433. 6312a49aab5aabd6371518dcaf081f489dff04d001bc34b4fe3f2a81170bbd4e flatpress.tar.gz
  1434. #+END_SRC
  1435. Extract and install it.
  1436. #+BEGIN_SRC: bash
  1437. tar -xzvf flatpress.tar.gz
  1438. cd flatpress-*
  1439. cp -r * /var/www/$HOSTNAME/htdocs
  1440. rm -rf flatpress-*
  1441. rm -f flatpress.tar.gz
  1442. #+END_SRC
  1443. 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
  1444. ** Install an IRC server
  1445. #+BEGIN_VERSE
  1446. /Give me the liberty to know, to utter, and to argue freely according to conscience, above all liberties./
  1447. -- John Milton
  1448. #+END_VERSE
  1449. *** Base install
  1450. 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.
  1451. First install some dependencies.
  1452. #+BEGIN_SRC: bash
  1453. apt-get update
  1454. apt-get install build-essential openssl libssl-dev
  1455. #+END_SRC
  1456. Then get the source code for ircd-hybrid.
  1457. #+BEGIN_SRC: bash
  1458. cd /tmp
  1459. mkdir hybrid
  1460. cd hybrid
  1461. apt-get source ircd-hybrid
  1462. #+END_SRC
  1463. Modify the source code to include SSL security.
  1464. #+BEGIN_SRC: bash
  1465. emacs ircd-hybrid-*/debian/rules
  1466. #+END_SRC
  1467. Beneath MAXCLIENTS add the line:
  1468. #+BEGIN_SRC: bash
  1469. USE_OPENSSL = 1
  1470. #+END_SRC
  1471. Then save and exit. Now we can build the debian package for ircd-hybrid and install it.
  1472. #+BEGIN_SRC: bash
  1473. cd ircd-hybrid-*
  1474. dpkg-buildpackage -rfakeroot -uc -b
  1475. cd ..
  1476. dpkg -i ircd-hybrid_*.deb
  1477. #+END_SRC
  1478. 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.
  1479. #+BEGIN_SRC: bash
  1480. emacs /etc/ircd-hybrid/ircd.conf
  1481. #+END_SRC
  1482. Set *name* to the name of your server, and set a description.
  1483. Set a *network_name* and *network_desc*. The network name should not contain any spaces.
  1484. Set max_clients to 20, or however many you expect that you'll typically need.
  1485. Within the admin section set your *name* and *email*.
  1486. Within the *listen* section set host to your fixed IP address (in the earlier
  1487. sections it was 192.168.1.60).
  1488. Within the *auth* section set user = "*@192.168.1.60" - or whatever the fixed IP address of the BBB is on your network.
  1489. 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.
  1490. Save and exit, then restart the IRC server. Open port 6670 on your internet router and forward it to the BBB.
  1491. Ensure that the configuration is only readable by the root user.
  1492. #+BEGIN_SRC: bash
  1493. chmod 600 /etc/ircd-hybrid/ircd.conf
  1494. #+END_SRC
  1495. *** Channel management
  1496. To to install channel management tools.
  1497. #+BEGIN_SRC: bash
  1498. cd /tmp
  1499. wget http://freedombone.uk.to/hybserv_1.9.4-1_armhf.deb
  1500. #+END_SRC
  1501. Verify it.
  1502. #+BEGIN_SRC: bash
  1503. sha256sum hybserv_1.9.4-1_armhf.deb
  1504. 41bf4eb6e24c87610a80bc14db1103a57484835510eea7e4ba9709c523318615 hybserv_1.9.4-1_armhf.deb
  1505. #+END_SRC
  1506. Install it.
  1507. #+BEGIN_SRC: bash
  1508. dpkg -i hybserv_1.9.4-1_armhf.deb
  1509. #+END_SRC
  1510. Make a md5 version of the password for the IRC server operator.
  1511. #+BEGIN_SRC: bash
  1512. /usr/bin/mkpasswd <myoperatorpassword>
  1513. #+END_SRC
  1514. Edit the ircd-hybrid configuration.
  1515. #+BEGIN_SRC: bash
  1516. emacs /etc/ircd-hybrid/ircd.conf
  1517. #+END_SRC
  1518. Enter the md5 password which you previously created within the /operator/ section. Also change /user/ to:
  1519. #+BEGIN_SRC: bash
  1520. user = "*@*";
  1521. #+END_SRC
  1522. Then save and exit.
  1523. #+BEGIN_SRC: bash
  1524. emacs /etc/hybserv/hybserv.conf
  1525. #+END_SRC
  1526. 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/.
  1527. #+BEGIN_SRC: bash
  1528. A:mynickname <myemailaddress>
  1529. N:irc.mydomainname.com:Hybrid services
  1530. O:*@*:#MD5 PASSWORD HERE#:root:segj (comment out other Q: lines)
  1531. S:mysendacceptpassword:192.168.1.60:6670 (remove the other two services)
  1532. #+END_SRC
  1533. Also remove the line *#NOT-EDITED#*, then save and exit.
  1534. Now we need to restart the ircd and hybrid server to make things work:
  1535. #+BEGIN_SRC: bash
  1536. service ircd-hybrid restart
  1537. service hybserv start
  1538. #+END_SRC
  1539. *** Usage
  1540. On another computer (not the BBB).
  1541. #+BEGIN_SRC: bash
  1542. sudo apt-get install irssi
  1543. irssi
  1544. #+END_SRC
  1545. Connect to the IRC and identify yourself as an operator. Here /mynetwork/ should be the same as *network_name* specified earlier within /ircd.conf/.
  1546. #+BEGIN_SRC: bash
  1547. /server add -auto -network mynetwork -ssl mydonainname.com 6670 mysendacceptpassword
  1548. /connect mydomainname.com
  1549. /channel add -auto #mychannel mynetwork channelpassword
  1550. /network add -nick mynick mychannel
  1551. /join #mychannel
  1552. /msg -servername chanserv REGISTER #mychannel channelpassword
  1553. /msg -servername chanserv set #mychannel mlock +k channelpassword
  1554. #+END_SRC
  1555. If you edit the irssi config file:
  1556. #+BEGIN_SRC: bash
  1557. emacs ~/.irssi/config
  1558. #+END_SRC
  1559. It should look something like this:
  1560. #+BEGIN_SRC: bash
  1561. {
  1562. address = "mydomainname.com";
  1563. chatnet = "mynetwork";
  1564. port = "6670";
  1565. password = "mysendacceptpassword";
  1566. use_ssl = "yes";
  1567. ssl_verify = "no";
  1568. autoconnect = "yes";
  1569. },
  1570. #+END_SRC
  1571. If you're not using a self-signed certificate (self-signed is the default) then you can set *ssl_verify* to "yes".
  1572. ** Install a Jabber/XMPP server
  1573. #+BEGIN_VERSE
  1574. /Well heck, it isn’t that hard to write an instant messaging system./
  1575. --Jeremie Miller
  1576. #+END_VERSE
  1577. *** The Server
  1578. Generate a SSL certificate.
  1579. #+BEGIN_SRC: bash
  1580. openssl ecparam -out /etc/ssl/private/xmpp.pem -name prime256v1
  1581. openssl genpkey -paramfile /etc/ssl/private/xmpp.pem -out /etc/ssl/private/xmpp.key
  1582. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  1583. #+END_SRC
  1584. 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:
  1585. #+BEGIN_SRC: bash
  1586. openssl genrsa -out /etc/ssl/private/xmpp.key 4096
  1587. openssl req -new -x509 -key /etc/ssl/private/xmpp.key -out /etc/ssl/certs/xmpp.crt -days 3650
  1588. #+END_SRC
  1589. Change permissions.
  1590. #+BEGIN_SRC: bash
  1591. chmod 600 /etc/ssl/private/xmpp.key
  1592. chmod 600 /etc/ssl/certs/xmpp.crt
  1593. chown prosody:prosody /etc/ssl/private/xmpp.key
  1594. chown prosody:prosody /etc/ssl/certs/xmpp.crt
  1595. #+END_SRC
  1596. Install Prosody.
  1597. #+BEGIN_SRC: bash
  1598. apt-get install prosody
  1599. cp -a /etc/prosody/conf.avail/example.com.cfg.lua /etc/prosody/conf.avail/xmpp.cfg.lua
  1600. emacs /etc/prosody/conf.avail/xmpp.cfg.lua
  1601. #+END_SRC
  1602. Change the *VirtualHost* name to your domain name and remove the line below it.
  1603. Set the ssl section to:
  1604. #+BEGIN_SRC: bash
  1605. ssl = {
  1606. key = "/etc/ssl/private/xmpp.key";
  1607. certificate = "/etc/ssl/certs/xmpp.crt";
  1608. }
  1609. #+END_SRC
  1610. And also append the following:
  1611. #+BEGIN_SRC: bash
  1612. modules_enabled = {
  1613. "bosh"; -- Enable mod_bosh
  1614. "tls"; -- Enable mod_tls
  1615. }
  1616. c2s_require_encryption = true
  1617. s2s_require_encryption = true
  1618. #+END_SRC
  1619. Save and exit. Create a symbolic link.
  1620. #+BEGIN_SRC: bash
  1621. ln -sf /etc/prosody/conf.avail/xmpp.cfg.lua /etc/prosody/conf.d/xmpp.cfg.lua
  1622. #+END_SRC
  1623. 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).
  1624. #+BEGIN_SRC: bash
  1625. prosodyctl adduser myusername@mydomainname.com
  1626. #+END_SRC
  1627. Restart the server
  1628. #+BEGIN_SRC: bash
  1629. service prosody restart
  1630. #+END_SRC
  1631. On your internet router/firewall open ports 5222, 5223, 5269, 5280 and 5281 and forward them to the BBB.
  1632. 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.
  1633. *** Managing users
  1634. To add a user:
  1635. #+BEGIN_SRC: bash
  1636. prosodyctl adduser myusername@mydomainname.com
  1637. #+END_SRC
  1638. To change a user password:
  1639. #+BEGIN_SRC: bash
  1640. prosodyctl passwd myusername@mydomainname.com
  1641. #+END_SRC
  1642. To remove a user:
  1643. #+BEGIN_SRC: bash
  1644. prosodyctl deluser myusername@mydomainname.com
  1645. #+END_SRC
  1646. Report the status of the XMPP server:
  1647. #+BEGIN_SRC: bash
  1648. prosodyctl status
  1649. #+END_SRC
  1650. *** Using with Jitsi
  1651. 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.
  1652. Jitsi can be downloaded from https://jitsi.org/
  1653. On your desktop/laptop open Jitsi and select *Options* from the *Tools* menu.
  1654. 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).
  1655. 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.
  1656. 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.
  1657. You can also [[https://www.youtube.com/watch?v=vgx7VSrDGjk][see this video]] as an example of using OTR.
  1658. *** Using with Ubuntu
  1659. 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.
  1660. Open *System Settings* and select *Online Accounts*, *Add account* and then *Jabber*.
  1661. Enter your username (myusername@mydomainname.com) and password.
  1662. 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*.
  1663. *** Using with Android
  1664. There are a few XMPP clients available on Android. Ideally choose ones which support off-the-record messaging. Here are some examples.
  1665. **** Xabber
  1666. Install [[https://f-droid.org/][F-Droid]]
  1667. Search for and install Xabber.
  1668. Add an account and enter your Jabber/XMPP ID and password.
  1669. From the menu select *Settings* then *Security* then *OTR mode*. Set the mode to *Required*.
  1670. Make sure that *Check server certificate* is not checked.
  1671. 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.
  1672. **** Gibberbot
  1673. Install [[https://f-droid.org/][F-Droid]]
  1674. Search for and install Gibberbot, otherwise known as ChatSecure.
  1675. From the menu open *Accounts*
  1676. Select *Add account*
  1677. Change the server port from 0 to 5222
  1678. Done
  1679. Accept unknown certificate? Select *Always*
  1680. Go back to the initial screen and then using the menu you can add contacts and begin chatting.
  1681. ** Social Networking
  1682. #+BEGIN_VERSE
  1683. /Facebook is not your friend, it is a surveillance engine./
  1684. -- Richard Stallman, Free Software Foundation
  1685. #+END_VERSE
  1686. *** Friendica
  1687. **** Installation
  1688. 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.
  1689. 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:
  1690. #+BEGIN_SRC: bash
  1691. emacs /etc/apache2/sites-available/mydomainname.com
  1692. #+END_SRC
  1693. Within the section which begins with *<VirtualHost *:80>* change the following:
  1694. #+BEGIN_SRC: bash
  1695. <Directory /var/www/mydomainname.com/htdocs/>
  1696. deny from all
  1697. </Directory>
  1698. #+END_SRC
  1699. Save and exit, then restart the apache server.
  1700. #+BEGIN_SRC: bash
  1701. service apache2 restart
  1702. #+END_SRC
  1703. Now install some dependencies.
  1704. #+BEGIN_SRC: bash
  1705. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  1706. #+END_SRC
  1707. Enter an admin password for MySQL.
  1708. Create a mysql database.
  1709. #+BEGIN_SRC: bash
  1710. mysql -u root -p
  1711. create database friendica;
  1712. CREATE USER 'friendicaadmin'@'localhost' IDENTIFIED BY 'password';
  1713. GRANT ALL PRIVILEGES ON friendica.* TO 'friendicaadmin'@'localhost';
  1714. quit
  1715. #+END_SRC
  1716. You may need to fix Git SSL problems.
  1717. #+BEGIN_SRC: bash
  1718. git config --global http.sslVerify true
  1719. apt-get install ca-certificates
  1720. cd ~/
  1721. emacs .gitconfig
  1722. #+END_SRC
  1723. The .gitconfig file should look something like this:
  1724. #+BEGIN_SRC: bash
  1725. [http]
  1726. sslVerify = true
  1727. sslCAinfo = /etc/ssl/certs/ca-certificates.crt
  1728. [user]
  1729. email = myusername@mydomainname.com
  1730. name = yourname
  1731. #+END_SRC
  1732. Get the source code.
  1733. #+BEGIN_SRC: bash
  1734. export HOSTNAME=mydomainname.com
  1735. cd /var/www/$HOSTNAME
  1736. mv htdocs htdocs_old
  1737. git clone https://github.com/friendica/friendica.git htdocs
  1738. chmod -R 755 htdocs
  1739. chown -R www-data:www-data htdocs
  1740. chown -R www-data:www-data htdocs/view/smarty3
  1741. git clone https://github.com/friendica/friendica-addons.git htdocs/addon
  1742. #+END_SRC
  1743. 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.
  1744. Install the poller.
  1745. #+BEGIN_SRC: bash
  1746. emacs /etc/crontab
  1747. #+END_SRC
  1748. and append the following, changing mydomainname.com to whatever your domain is.
  1749. #+BEGIN_SRC: bash
  1750. */10 * * * * root cd /var/www/mydomainname.com/htdocs; /usr/bin/php include/poller.php
  1751. #+END_SRC
  1752. Save and exit, then restart cron.
  1753. #+BEGIN_SRC: bash
  1754. service cron restart
  1755. #+END_SRC
  1756. You can improve the speed of Friendica database searches by adding the following indexes:
  1757. #+BEGIN_SRC: bash
  1758. mysql -u root -p
  1759. use friendica;
  1760. CREATE INDEX `uri_received` ON item(`uri`, `received`);
  1761. CREATE INDEX `received_uri` ON item(`received`, `uri`);
  1762. CREATE INDEX `contact-id_created` ON item(`contact-id`, created);
  1763. CREATE INDEX `uid_network_received` ON item(`uid`, `network`, `received`);
  1764. CREATE INDEX `uid_parent` ON item(`uid`, `parent`);
  1765. CREATE INDEX `uid_received` ON item(`uid`, `received`);
  1766. CREATE INDEX `uid_network_commented` ON item(`uid`, `network`, `commented`);
  1767. CREATE INDEX `uid_title` ON item(uid, `title`);
  1768. CREATE INDEX `created_contact-id` ON item(`created`, `contact-id`);
  1769. quit
  1770. #+END_SRC
  1771. Make sure that Friendica doesn't use too much memory.
  1772. #+BEGIN_SRC: bash
  1773. emacs /var/www/$HOSTNAME/htdocs/.htaccess
  1774. #+END_SRC
  1775. Append the following:
  1776. #+BEGIN_SRC: bash
  1777. php_value memory_limit 32M
  1778. #+END_SRC
  1779. The save ane exit.
  1780. **** Backups
  1781. 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.
  1782. #+BEGIN_SRC: bash
  1783. emacs /etc/cron.daily/friendicabackup
  1784. #+END_SRC
  1785. Enter the following
  1786. #+BEGIN_SRC: bash
  1787. #!/bin/sh
  1788. MYSQL_PASSWORD=<mysql root password>
  1789. umask 0077
  1790. # Backup the database
  1791. mysqldump --password=$MYSQL_PASSWORD friendica > /var/backups/friendica_daily.sql
  1792. # Make the backup readable only by root
  1793. chmod 600 /var/backups/friendica_daily.sql
  1794. #+END_SRC
  1795. Save and exit.
  1796. #+BEGIN_SRC: bash
  1797. chmod 600 /etc/cron.daily/friendicabackup
  1798. chmod +x /etc/cron.daily/friendicabackup
  1799. emacs /etc/cron.weekly/friendicabackup
  1800. #+END_SRC
  1801. Enter the following
  1802. #+BEGIN_SRC: bash
  1803. #!/bin/sh
  1804. MYSQL_PASSWORD=<mysql root password>
  1805. umask 0077
  1806. # Backup the database
  1807. mysqldump --password=$MYSQL_PASSWORD friendica > /var/backups/friendica_weekly.sql
  1808. # Make the backup readable only by root
  1809. chmod 600 /var/backups/friendica_weekly.sql
  1810. #+END_SRC
  1811. Save and exit.
  1812. #+BEGIN_SRC: bash
  1813. chmod 600 /etc/cron.weekly/friendicabackup
  1814. chmod +x /etc/cron.weekly/friendicabackup
  1815. #+END_SRC
  1816. **** Recommended configuration
  1817. ***** Admin
  1818. 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.
  1819. 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.
  1820. Under the *themes* section select a few themes, including mobile themes which are suitable for phones or tablets.
  1821. 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.
  1822. 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]].
  1823. ***** Settings
  1824. Each user has their own customisable settings, typically available either via an icon or by an entry on a drop down menu.
  1825. Under *additional features* enable "/richtext editor/", "/post preview/", "/group filter/", "/network filter/", "/edit sent posts/" and "/dislike posts/".
  1826. Under *display settings* select your desktop and mobile themes.
  1827. 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.
  1828. **** To access from an Android device
  1829. ***** App
  1830. 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.
  1831. 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.
  1832. More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
  1833. ***** Mobile Theme
  1834. 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.
  1835. *** Movim
  1836. #+BEGIN_VERSE
  1837. /The way we communicate with others and with ourselves ultimately determines the quality of our lives/
  1838. -- Anthony Robbins
  1839. #+END_VERSE
  1840. Movim is another social networking system based around the XMPP protocol.
  1841. You will need to have previously [[Install a Jabber/XMPP server][installed the Jabber/XMPP server]].
  1842. 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:
  1843. #+BEGIN_SRC: bash
  1844. emacs /etc/apache2/sites-available/mydomainname.com
  1845. #+END_SRC
  1846. Within the section which begins with *<VirtualHost *:80>* add the following:
  1847. #+BEGIN_SRC: bash
  1848. <Directory /var/www/mydomainname.com/htdocs/movim>
  1849. deny from all
  1850. </Directory>
  1851. #+END_SRC
  1852. Within the section which begins with *<VirtualHost *:443>* add the following:
  1853. #+BEGIN_SRC: bash
  1854. <Directory /var/www/mydomainname.com/htdocs/movim>
  1855. Options Indexes FollowSymLinks MultiViews
  1856. AllowOverride All
  1857. Order allow,deny
  1858. allow from all
  1859. </Directory>
  1860. #+END_SRC
  1861. Save and exit, then restart the apache server.
  1862. #+BEGIN_SRC: bash
  1863. service apache2 restart
  1864. #+END_SRC
  1865. Download the source.
  1866. #+BEGIN_SRC: bash
  1867. cd /tmp
  1868. wget http://freedombone.uk.to/movim.tar.gz
  1869. #+END_SRC
  1870. Verify it.
  1871. #+BEGIN_SRC: bash
  1872. sha256sum movim.tar.gz
  1873. 2740ddbedf6cefcc2934759374376643b6cdea4fb7f944ec25098a6868cb499e movim.tar.gz
  1874. #+END_SRC
  1875. Install it.
  1876. #+BEGIN_SRC: bash
  1877. tar -xzvf movim.tar.gz
  1878. export HOSTNAME=mydomainname.com
  1879. cp -r movim-* /var/www/$HOSTNAME/htdocs/movim
  1880. chmod 755 /var/www/$HOSTNAME/htdocs/movim
  1881. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/movim
  1882. #+END_SRC
  1883. Install some MySql prerequisites.
  1884. #+BEGIN_SRC: bash
  1885. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  1886. #+END_SRC
  1887. If necessary, enter an admin password for MySQL.
  1888. Create a mysql database.
  1889. #+BEGIN_SRC: bash
  1890. mysql -u root -p
  1891. create database movim;
  1892. CREATE USER 'movimadmin'@'localhost' IDENTIFIED BY 'movimadminpassword';
  1893. GRANT ALL PRIVILEGES ON movim.* TO 'movimadmin'@'localhost';
  1894. quit
  1895. #+END_SRC
  1896. With a web browser navigate to:
  1897. https://mydomainname.com/movim/admin
  1898. Enter /admin/ as the username and /password/ as the password.
  1899. 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).
  1900. Change the /Environment/ from /Development/ to /Production/.
  1901. 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?)
  1902. Click /Submit/ followed by /Resend/.
  1903. Click on /Database Settings/ and alter the MySql movim database username to /movimadmin/ and password to the password you specified in the previous step.
  1904. 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".
  1905. 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).
  1906. *** Red Matrix
  1907. **** Introduction
  1908. 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.
  1909. **** Prerequisites
  1910. 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.
  1911. 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.
  1912. **** Installation
  1913. 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.
  1914. 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:
  1915. #+BEGIN_SRC: bash
  1916. emacs /etc/apache2/sites-available/mydomainname.com
  1917. #+END_SRC
  1918. Within the section which begins with *<VirtualHost *:80>* change the following:
  1919. #+BEGIN_SRC: bash
  1920. <Directory /var/www/mydomainname.com/htdocs/>
  1921. deny from all
  1922. </Directory>
  1923. #+END_SRC
  1924. Save and exit, then restart the apache server.
  1925. #+BEGIN_SRC: bash
  1926. service apache2 restart
  1927. #+END_SRC
  1928. Now install some dependencies.
  1929. #+BEGIN_SRC: bash
  1930. apt-get install mysql-server php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt
  1931. #+END_SRC
  1932. Enter an admin password for MySQL.
  1933. Create a mysql database.
  1934. #+BEGIN_SRC: bash
  1935. mysql -u root -p
  1936. create database redmatrix;
  1937. CREATE USER 'redmatrixadmin'@'localhost' IDENTIFIED BY 'password';
  1938. GRANT ALL PRIVILEGES ON redmatrix.* TO 'redmatrixadmin'@'localhost';
  1939. quit
  1940. #+END_SRC
  1941. You may need to fix Git SSL problems.
  1942. #+BEGIN_SRC: bash
  1943. git config --global http.sslVerify true
  1944. apt-get install ca-certificates
  1945. cd ~/
  1946. emacs .gitconfig
  1947. #+END_SRC
  1948. The .gitconfig file should look something like this:
  1949. #+BEGIN_SRC: bash
  1950. [http]
  1951. sslVerify = true
  1952. sslCAinfo = /etc/ssl/certs/ca-certificates.crt
  1953. [user]
  1954. email = myusername@mydomainname.com
  1955. name = yourname
  1956. #+END_SRC
  1957. Get the source code.
  1958. #+BEGIN_SRC: bash
  1959. export HOSTNAME=mydomainname.com
  1960. cd /var/www/$HOSTNAME
  1961. mv htdocs htdocs_old
  1962. git clone https://github.com/friendica/red.git htdocs
  1963. chmod -R 755 htdocs
  1964. chown -R www-data:www-data htdocs
  1965. mkdir htdocs/view/tpl/smarty3
  1966. chmod 777 htdocs/view/tpl
  1967. chmod 777 htdocs/view/tpl/smarty3
  1968. git clone https://github.com/friendica/red-addons.git htdocs/addon
  1969. #+END_SRC
  1970. 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.
  1971. Install the poller.
  1972. #+BEGIN_SRC
  1973. emacs /etc/crontab
  1974. #+END_SRC
  1975. and append the following, changing mydomainname.com to whatever your domain is.
  1976. #+BEGIN_SRC
  1977. */10 * * * * root cd /var/www/mydomainname.com/htdocs; /usr/bin/php include/poller.php
  1978. #+END_SRC
  1979. Save and exit, then restart cron.
  1980. #+BEGIN_SRC: bash
  1981. service cron restart
  1982. #+END_SRC
  1983. **** Backups
  1984. 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.
  1985. #+BEGIN_SRC: bash
  1986. emacs /etc/cron.daily/redmatrixbackup
  1987. #+END_SRC
  1988. Enter the following
  1989. #+BEGIN_SRC: bash
  1990. #!/bin/sh
  1991. MYSQL_PASSWORD=<mysql root password>
  1992. umask 0077
  1993. # Backup the database
  1994. mysqldump --password=$MYSQL_PASSWORD redmatrix > /var/backups/redmatrix_daily.sql
  1995. # Make the backup readable only by root
  1996. chmod 600 /var/backups/redmatrix_daily.sql
  1997. #+END_SRC
  1998. Save and exit.
  1999. #+BEGIN_SRC: bash
  2000. chmod 600 /etc/cron.daily/redmatrixbackup
  2001. chmod +x /etc/cron.daily/redmatrixbackup
  2002. emacs /etc/cron.weekly/redmatrixbackup
  2003. #+END_SRC
  2004. Enter the following
  2005. #+BEGIN_SRC: bash
  2006. #!/bin/sh
  2007. MYSQL_PASSWORD=<mysql root password>
  2008. umask 0077
  2009. # Backup the database
  2010. mysqldump --password=$MYSQL_PASSWORD redmatrix > /var/backups/redmatrix_weekly.sql
  2011. # Make the backup readable only by root
  2012. chmod 600 /var/backups/redmatrix_weekly.sql
  2013. #+END_SRC
  2014. Save and exit.
  2015. #+BEGIN_SRC: bash
  2016. chmod 600 /etc/cron.weekly/redmatrixbackup
  2017. chmod +x /etc/cron.weekly/redmatrixbackup
  2018. #+END_SRC
  2019. **** To access from an Android device
  2020. ***** App
  2021. 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.
  2022. 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.
  2023. More information about the Friendica app can be found on http://friendica-for-android.wiki-lab.net/
  2024. ** Install Gopher
  2025. 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.
  2026. To set up a gopher server:
  2027. #+BEGIN_SRC: bash
  2028. apt-get install build-essential
  2029. cd /tmp
  2030. wget http://freedombone.uk.to/geomyidae-current.tgz
  2031. #+END_SRC
  2032. Verify the download:
  2033. #+BEGIN_SRC: bash
  2034. sha256sum geomyidae-current.tgz
  2035. 162f55ab059ab0a9be8e840497795293bbd51c34b1f4564dcdf3f0ddd5c0db31 geomyidae-current.tgz
  2036. #+END_SRC
  2037. Then extract and install it.
  2038. #+BEGIN_SRC: bash
  2039. tar -xzvf geomyidae-current.tgz
  2040. cd geomyidae-*
  2041. make
  2042. make install
  2043. mkdir -p /var/gopher
  2044. #+END_SRC
  2045. 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.
  2046. #+BEGIN_SRC: bash
  2047. emacs /etc/init.d/gopher
  2048. #+END_SRC
  2049. Enter the following:
  2050. #+BEGIN_SRC: bash
  2051. #! /bin/sh
  2052. ### BEGIN INIT INFO
  2053. # Provides: gopher
  2054. # Required-Start: $remote_fs $syslog
  2055. # Required-Stop: $remote_fs $syslog
  2056. # Default-Start: 2 3 4 5
  2057. # Default-Stop: 0 1 6
  2058. # Short-Description: Gopher daemon
  2059. # Description: Gopher daemon
  2060. ### END INIT INFO
  2061. # Do NOT "set -e"
  2062. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  2063. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  2064. DESC="Gopher daemon"
  2065. NAME=geomyidae
  2066. DAEMON=/usr/bin/$NAME
  2067. DAEMON_ARGS="-l /var/log/geomyidae.log -b /var/gopher -p 70"
  2068. PIDFILE=/var/run/$NAME.pid
  2069. SCRIPTNAME=/etc/init.d/$NAME
  2070. # Exit if the package is not installed
  2071. [ -x "$DAEMON" ] || exit 0
  2072. # Read configuration variable file if it is present
  2073. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  2074. # Load the VERBOSE setting and other rcS variables
  2075. . /lib/init/vars.sh
  2076. # Define LSB log_* functions.
  2077. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
  2078. # and status_of_proc is working.
  2079. . /lib/lsb/init-functions
  2080. #
  2081. # Function that starts the daemon/service
  2082. #
  2083. do_start()
  2084. {
  2085. # Return
  2086. # 0 if daemon has been started
  2087. # 1 if daemon was already running
  2088. # 2 if daemon could not be started
  2089. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
  2090. || return 1
  2091. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
  2092. $DAEMON_ARGS \
  2093. || return 2
  2094. # Add code here, if necessary, that waits for the process to be ready
  2095. # to handle requests from services started subsequently which depend
  2096. # on this one. As a last resort, sleep for some time.
  2097. }
  2098. #
  2099. # Function that stops the daemon/service
  2100. #
  2101. do_stop()
  2102. {
  2103. # Return
  2104. # 0 if daemon has been stopped
  2105. # 1 if daemon was already stopped
  2106. # 2 if daemon could not be stopped
  2107. # other if a failure occurred
  2108. start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
  2109. RETVAL="$?"
  2110. [ "$RETVAL" = 2 ] && return 2
  2111. # Wait for children to finish too if this is a daemon that forks
  2112. # and if the daemon is only ever run from this initscript.
  2113. # If the above conditions are not satisfied then add some other code
  2114. # that waits for the process to drop all resources that could be
  2115. # needed by services started subsequently. A last resort is to
  2116. # sleep for some time.
  2117. start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
  2118. [ "$?" = 2 ] && return 2
  2119. # Many daemons don't delete their pidfiles when they exit.
  2120. rm -f $PIDFILE
  2121. return "$RETVAL"
  2122. }
  2123. #
  2124. # Function that sends a SIGHUP to the daemon/service
  2125. #
  2126. do_reload() {
  2127. #
  2128. # If the daemon can reload its configuration without
  2129. # restarting (for example, when it is sent a SIGHUP),
  2130. # then implement that here.
  2131. #
  2132. start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
  2133. return 0
  2134. }
  2135. case "$1" in
  2136. start)
  2137. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  2138. do_start
  2139. case "$?" in
  2140. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  2141. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  2142. esac
  2143. ;;
  2144. stop)
  2145. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  2146. do_stop
  2147. case "$?" in
  2148. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  2149. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  2150. esac
  2151. ;;
  2152. status)
  2153. status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  2154. ;;
  2155. #reload|force-reload)
  2156. #
  2157. # If do_reload() is not implemented then leave this commented out
  2158. # and leave 'force-reload' as an alias for 'restart'.
  2159. #
  2160. #log_daemon_msg "Reloading $DESC" "$NAME"
  2161. #do_reload
  2162. #log_end_msg $?
  2163. #;;
  2164. restart|force-reload)
  2165. #
  2166. # If the "reload" option is implemented then remove the
  2167. # 'force-reload' alias
  2168. #
  2169. log_daemon_msg "Restarting $DESC" "$NAME"
  2170. do_stop
  2171. case "$?" in
  2172. 0|1)
  2173. do_start
  2174. case "$?" in
  2175. 0) log_end_msg 0 ;;
  2176. 1) log_end_msg 1 ;; # Old process is still running
  2177. *) log_end_msg 1 ;; # Failed to start
  2178. esac
  2179. ;;
  2180. *)
  2181. # Failed to stop
  2182. log_end_msg 1
  2183. ;;
  2184. esac
  2185. ;;
  2186. *)
  2187. #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  2188. echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
  2189. exit 3
  2190. ;;
  2191. esac
  2192. :
  2193. #+END_SRC
  2194. Save and exit. Then start the gopher service.
  2195. #+BEGIN_SRC: bash
  2196. chmod +x /etc/init.d/gopher
  2197. update-rc.d gopher defaults
  2198. service gopher start
  2199. #+END_SRC
  2200. 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:
  2201. #+BEGIN_SRC: bash
  2202. gopher://mydomainname.com
  2203. #+END_SRC
  2204. There is a browser addon for Gopher called "overbite". Installing that should enable you to view your site.
  2205. ** Install Owncloud
  2206. #+BEGIN_VERSE
  2207. /It's not water vapour/
  2208. -- Larry Ellison
  2209. #+END_VERSE
  2210. 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.
  2211. *** Server Installation
  2212. Install some dependencies:
  2213. #+BEGIN_SRC: bash
  2214. apt-get install apache2 php5 php5-gd php-xml-parser php5-intl
  2215. apt-get install php5-sqlite php5-mysql smbclient curl libcurl3 php5-curl
  2216. #+END_SRC
  2217. 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.
  2218. #+BEGIN_SRC: bash
  2219. a2dismod php5filter
  2220. apt-get install libapache2-mod-php5
  2221. #+END_SRC
  2222. Ensure that the size of files which may be uploaded or downloaded is large enough.
  2223. #+BEGIN_SRC: bash
  2224. emacs /etc/php5/apache2/php.ini
  2225. #+END_SRC
  2226. Set the following:
  2227. #+BEGIN_SRC: bash
  2228. upload_max_filesize = 512M
  2229. post_max_size = 512M
  2230. #+END_SRC
  2231. Save and exit, then edit your Apache configuration.
  2232. #+BEGIN_SRC: bash
  2233. export HOSTNAME=mydomainname.com
  2234. emacs /etc/apache2/sites-available/$HOSTNAME
  2235. #+END_SRC
  2236. 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.
  2237. #+BEGIN_SRC: bash
  2238. <Directory /var/www/mydomainname.com/htdocs/owncloud>
  2239. Options Indexes FollowSymLinks MultiViews
  2240. AllowOverride All
  2241. Order allow,deny
  2242. allow from all
  2243. </Directory>
  2244. #+END_SRC
  2245. To ensure that nobody logs in insecurely add the following to the 80 VirtualHost section.
  2246. #+BEGIN_SRC: bash
  2247. <Directory /var/www/mydomainname.com/htdocs/owncloud>
  2248. deny from all
  2249. </Directory>
  2250. #+END_SRC
  2251. Save and exit, then restart apache.
  2252. #+BEGIN_SRC: bash
  2253. service apache2 restart
  2254. #+END_SRC
  2255. Download owncloud.
  2256. #+BEGIN_SRC: bash
  2257. cd /tmp
  2258. wget http://freedombone.uk.to/owncloud.tar.bz2
  2259. #+END_SRC
  2260. Verify the download:
  2261. #+BEGIN_SRC: bash
  2262. sha256sum owncloud.tar.bz2
  2263. 92b53fdfa7c4165b83dd2f8447f63928454a5815d08ff2d6165dd1a8969ecbe1 owncloud.tar.bz2
  2264. #+END_SRC
  2265. Extract the archive. This may take a couple of minutes, so don't be alarmed that the system has crashed.
  2266. #+BEGIN_SRC: bash
  2267. export HOSTNAME=mydomainname.com
  2268. tar -xjf owncloud.tar.bz2
  2269. #+END_SRC
  2270. Move the extracted files to your site and set file permissions.
  2271. #+BEGIN_SRC: bash
  2272. cp -r owncloud /var/www/$HOSTNAME/htdocs
  2273. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud/apps
  2274. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud/config
  2275. chown www-data:www-data /var/www/$HOSTNAME/htdocs/owncloud
  2276. #+END_SRC
  2277. Edit the htaccess file for Owncloud.
  2278. #+BEGIN_SRC: bash
  2279. emacs /var/www/$HOSTNAME/htdocs/owncloud/.htaccess
  2280. #+END_SRC
  2281. Set the following.
  2282. #+BEGIN_SRC: bash
  2283. php_value upload_max_filesize 512M
  2284. php_value post_max_size 512M
  2285. php_value memory_limit 32M
  2286. #+END_SRC
  2287. Save and exit.
  2288. With a web browser visit your domain (mydomainname.com/owncloud) and enter an administrator username and password.
  2289. *** Owncloud on Android
  2290. 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.
  2291. ** Install a Wiki
  2292. #+BEGIN_VERSE
  2293. /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./
  2294. -- Tom Barbalet
  2295. #+END_VERSE
  2296. Dokuwiki is based upon flat files, and so is easy to move from one server to another without a lot of database complications.
  2297. Download the wiki.
  2298. #+BEGIN_SRC: bash
  2299. cd /tmp
  2300. wget http://freedombone.uk.to/dokuwiki.tgz
  2301. #+END_SRC
  2302. Verify it.
  2303. #+BEGIN_SRC: bash
  2304. sha256sum dokuwiki.tgz
  2305. 6b126f90979463d9ddaa74acc6f96aa230cfdc789946f241c3646086d9574be8 dokuwiki.tgz
  2306. #+END_SRC
  2307. Then extract and install it.
  2308. #+BEGIN_SRC: bash
  2309. export HOSTNAME=mywikidomainname.com
  2310. tar -xzvf dokuwiki.tgz
  2311. mv /var/www/$HOSTNAME/htdocs /var/www/$HOSTNAME/htdocs_old
  2312. mv dokuwiki /var/www/$HOSTNAME/htdocs
  2313. #+END_SRC
  2314. Edit the Apache configuration for your wiki site.
  2315. #+BEGIN_SRC: bash
  2316. emacs /etc/apache2/sites-available/$HOSTNAME
  2317. #+END_SRC
  2318. The settings should look something like the following. Replace /mywikidomainname.com/ with your wiki domain name.
  2319. #+BEGIN_SRC: bash
  2320. <VirtualHost *:80>
  2321. ServerAdmin myusername@mywikidomainname.com
  2322. ServerName mydomainname.com
  2323. DocumentRoot /var/www/mywikidomainname.com/htdocs
  2324. <Directory /var/www/mywikidomainname.com/htdocs>
  2325. order deny,allow
  2326. allow from all
  2327. </Directory>
  2328. <LocationMatch "/(data|conf|bin|inc)/">
  2329. order allow,deny
  2330. deny from all
  2331. satisfy all
  2332. </LocationMatch>
  2333. <Directory />
  2334. Options FollowSymLinks
  2335. AllowOverride All
  2336. </Directory>
  2337. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  2338. <Directory "/usr/lib/cgi-bin">
  2339. AllowOverride All
  2340. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  2341. Order allow,deny
  2342. Allow from all
  2343. </Directory>
  2344. ErrorLog ${APACHE_LOG_DIR}/error.log
  2345. # Possible values include: debug, info, notice, warn, error, crit,
  2346. # alert, emerg.
  2347. LogLevel error
  2348. CustomLog ${APACHE_LOG_DIR}/access.log combined
  2349. </VirtualHost>
  2350. <IfModule mod_ssl.c>
  2351. <VirtualHost *:443>
  2352. ServerAdmin myusername@mywikidomainname.com
  2353. ServerName mywikidomainname.com
  2354. DocumentRoot /var/www/mywikidomainname.com/htdocs
  2355. <Directory /var/www/mywikidomainname.com/htdocs>
  2356. order deny,allow
  2357. allow from all
  2358. </Directory>
  2359. <LocationMatch "/(data|conf|bin|inc)/">
  2360. order allow,deny
  2361. deny from all
  2362. satisfy all
  2363. </LocationMatch>
  2364. <Directory />
  2365. Options FollowSymLinks
  2366. AllowOverride All
  2367. </Directory>
  2368. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  2369. <Directory "/usr/lib/cgi-bin">
  2370. AllowOverride All
  2371. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  2372. Order allow,deny
  2373. Allow from all
  2374. </Directory>
  2375. ErrorLog ${APACHE_LOG_DIR}/error.log
  2376. # Possible values include: debug, info, notice, warn, error, crit,
  2377. # alert, emerg.
  2378. LogLevel error
  2379. CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
  2380. # SSL Engine Switch:
  2381. # Enable/Disable SSL for this virtual host.
  2382. SSLEngine on
  2383. # A self-signed certificate
  2384. SSLCertificateFile /etc/ssl/certs/mydomainname.com.crt
  2385. SSLCertificateKeyFile /etc/ssl/private/mydomainname.com.key
  2386. # Options based on bettercrypto.org
  2387. SSLProtocol All -SSLv2 -SSLv3
  2388. SSLHonorCipherOrder On
  2389. SSLCompression off
  2390. 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
  2391. # SSL Engine Options:
  2392. # Set various options for the SSL engine.
  2393. # o FakeBasicAuth:
  2394. # Translate the client X.509 into a Basic Authorisation. This means that
  2395. # the standard Auth/DBMAuth methods can be used for access control. The
  2396. # user name is the `one line' version of the client's X.509 certificate.
  2397. # Note that no password is obtained from the user. Every entry in the user
  2398. # file needs this password: `xxj31ZMTZzkVA'.
  2399. # o ExportCertData:
  2400. # This exports two additional environment variables: SSL_CLIENT_CERT and
  2401. # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
  2402. # server (always existing) and the client (only existing when client
  2403. # authentication is used). This can be used to import the certificates
  2404. # into CGI scripts.
  2405. # o StdEnvVars:
  2406. # This exports the standard SSL/TLS related `SSL_*' environment variables.
  2407. # Per default this exportation is switched off for performance reasons,
  2408. # because the extraction step is an expensive operation and is usually
  2409. # useless for serving static content. So one usually enables the
  2410. # exportation for CGI and SSI requests only.
  2411. # o StrictRequire:
  2412. # This denies access when "SSLRequireSSL" or "SSLRequire" applied even
  2413. # under a "Satisfy any" situation, i.e. when it applies access is denied
  2414. # and no other module can change it.
  2415. # o OptRenegotiate:
  2416. # This enables optimized SSL connection renegotiation handling when SSL
  2417. # directives are used in per-directory context.
  2418. #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
  2419. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  2420. SSLOptions +StdEnvVars
  2421. </FilesMatch>
  2422. <Directory /usr/lib/cgi-bin>
  2423. SSLOptions +StdEnvVars
  2424. </Directory>
  2425. # SSL Protocol Adjustments:
  2426. # The safe and default but still SSL/TLS standard compliant shutdown
  2427. # approach is that mod_ssl sends the close notify alert but doesn't wait for
  2428. # the close notify alert from client. When you need a different shutdown
  2429. # approach you can use one of the following variables:
  2430. # o ssl-unclean-shutdown:
  2431. # This forces an unclean shutdown when the connection is closed, i.e. no
  2432. # SSL close notify alert is send or allowed to received. This violates
  2433. # the SSL/TLS standard but is needed for some brain-dead browsers. Use
  2434. # this when you receive I/O errors because of the standard approach where
  2435. # mod_ssl sends the close notify alert.
  2436. # o ssl-accurate-shutdown:
  2437. # This forces an accurate shutdown when the connection is closed, i.e. a
  2438. # SSL close notify alert is send and mod_ssl waits for the close notify
  2439. # alert of the client. This is 100% SSL/TLS standard compliant, but in
  2440. # practice often causes hanging connections with brain-dead browsers. Use
  2441. # this only for browsers where you know that their SSL implementation
  2442. # works correctly.
  2443. # Notice: Most problems of broken clients are also related to the HTTP
  2444. # keep-alive facility, so you usually additionally want to disable
  2445. # keep-alive for those clients, too. Use variable "nokeepalive" for this.
  2446. # Similarly, one has to force some clients to use HTTP/1.0 to workaround
  2447. # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
  2448. # "force-response-1.0" for this.
  2449. BrowserMatch "MSIE [2-6]" \
  2450. nokeepalive ssl-unclean-shutdown \
  2451. downgrade-1.0 force-response-1.0
  2452. # MSIE 7 and newer should be able to use keepalive
  2453. BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  2454. </VirtualHost>
  2455. </IfModule>
  2456. #+END_SRC
  2457. Enable your site with:
  2458. #+BEGIN_SRC: bash
  2459. a2ensite
  2460. #+END_SRC
  2461. then select the domain name and reload.
  2462. #+BEGIN_SRC: bash
  2463. service apache2 reload
  2464. #+END_SRC
  2465. and alter permissions:
  2466. #+BEGIN_SRC: bash
  2467. chmod -R 755 /var/www/$HOSTNAME/htdocs
  2468. chown -R www-data:www-data /var/www/$HOSTNAME/htdocs
  2469. #+END_SRC
  2470. Open a browser and visit http://$HOSTNAME/install.php, then fill out the details. Once everything has been accepted without errors:
  2471. #+BEGIN_SRC: bash
  2472. rm /var/www/$HOSTNAME/htdocs/install.php
  2473. #+END_SRC
  2474. Add a few extra mime types:
  2475. #+BEGIN_SRC: bash
  2476. emacs /var/www/$HOSTNAME/htdocs/conf/mime.conf
  2477. #+END_SRC
  2478. Append the following:
  2479. #+BEGIN_SRC: bash
  2480. ogv video/ogg
  2481. mp4 video/mp4
  2482. webm video/webm
  2483. #+END_SRC
  2484. Save and exit.
  2485. 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*.
  2486. Now you can visit your wiki and begin editing.
  2487. ** Install Bitmessage
  2488. #+BEGIN_VERSE
  2489. /Love your neighbour. Fight the future. If you are reading this you ARE the resistance./
  2490. -- BitChirp
  2491. #+END_VERSE
  2492. *** A new kind of Email
  2493. [[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.
  2494. 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.
  2495. Installing Bitmessage as a daemon will increase the size of the network, and therefore the level of security for all users.
  2496. *** The Daemon
  2497. Install from the current source code.
  2498. #+BEGIN_SRC: bash
  2499. apt-get install python screen
  2500. cd /tmp
  2501. git clone https://github.com/Bitmessage/PyBitmessage.git
  2502. cd PyBitmessage
  2503. make install
  2504. #+END_SRC
  2505. Now create the daemon.
  2506. #+BEGIN_SRC: bash
  2507. emacs /etc/init.d/pybitmessage
  2508. #+END_SRC
  2509. Add the following text:
  2510. #+BEGIN_SRC: bash
  2511. #!/bin/bash
  2512. # /etc/init.d/bitmessage
  2513. ### BEGIN INIT INFO
  2514. # Provides: pybitmessage
  2515. # Required-Start: $remote_fs $syslog
  2516. # Required-Stop: $remote_fs $syslog
  2517. # Default-Start: 2 3 4 5
  2518. # Default-Stop: 0 1 6
  2519. # Short-Description: starts bitmessage as a background daemon, suitable for servers
  2520. # Description: This file should be used to construct scripts to be
  2521. # placed in /etc/init.d.
  2522. ### END INIT INFO
  2523. # Author: Super-Nathan <BM-Gu2k3Wy2hpTMYBxSoM2937SPcuU6xzEj>
  2524. #Settings
  2525. SERVICE='pybitmessage'
  2526. LOGFILE='/dev/null' # this disables logging
  2527. # LOGFILE='/var/log/bitmessage.log' # comment out the above line and un-comment this line to save a log
  2528. COMMAND="python bitmessagemain.py > $LOGFILE"
  2529. USERNAME='bitmsg'
  2530. NICELEVEL=19 # from 0-19 the bigger the number, the less the impact on system resources
  2531. HISTORY=1024
  2532. PBM_LOCATION="/usr/local/share/pybitmessage"
  2533. INVOCATION="nice -n ${NICELEVEL} ${COMMAND}"
  2534. PATH='/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl:/sbin:/usr/sbin:/bin:/usr/local/share/pybitmessage'
  2535. bm_start() {
  2536. echo "Starting $SERVICE..."
  2537. cd ${PBM_LOCATION}
  2538. su --command "screen -h ${HISTORY} -dmS ${SERVICE} ${INVOCATION}" $USERNAME
  2539. }
  2540. bm_stop() {
  2541. echo "Stopping $SERVICE"
  2542. su --command "screen -p 0 -S ${SERVICE} -X stuff "'^C'"" $USERNAME
  2543. }
  2544. #Start-Stop here
  2545. case "$1" in
  2546. start)
  2547. bm_start
  2548. ;;
  2549. stop)
  2550. bm_stop
  2551. ;;
  2552. restart)
  2553. bm_stop
  2554. sleep 60s
  2555. bm_start
  2556. ;;
  2557. *)
  2558. echo "Usage: $0 {start|stop|restart}"
  2559. exit 1
  2560. ;;
  2561. esac
  2562. exit 0
  2563. #+END_SRC
  2564. Save and exit.
  2565. 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.
  2566. #+BEGIN_SRC: bash
  2567. adduser bitmsg
  2568. #+END_SRC
  2569. Create a /keys.dat/ file which is used to configure Bitmessage.
  2570. #+BEGIN_SRC: bash
  2571. mkdir /home/bitmsg/.config
  2572. mkdir /home/bitmsg/.config/PyBitmessage
  2573. emacs /home/bitmsg/.config/PyBitmessage/keys.dat
  2574. #+END_SRC
  2575. Add the following:
  2576. #+BEGIN_SRC: bash
  2577. [bitmessagesettings]
  2578. settingsversion = 7
  2579. port = 8444
  2580. timeformat = %%a, %%d %%b %%Y %%I:%%M %%p
  2581. blackwhitelist = black
  2582. startonlogon = false
  2583. minimizetotray = false
  2584. showtraynotifications = false
  2585. startintray = false
  2586. socksproxytype = none
  2587. sockshostname = localhost
  2588. socksport = 9050
  2589. socksauthentication = false
  2590. sockslisten = false
  2591. socksusername =
  2592. sockspassword =
  2593. keysencrypted = false
  2594. messagesencrypted = false
  2595. defaultnoncetrialsperbyte = 640
  2596. defaultpayloadlengthextrabytes = 14000
  2597. minimizeonclose = false
  2598. maxacceptablenoncetrialsperbyte = 0
  2599. maxacceptablepayloadlengthextrabytes = 0
  2600. userlocale = system
  2601. namecoinrpctype = namecoind
  2602. namecoinrpchost = localhost
  2603. namecoinrpcuser =
  2604. namecoinrpcpassword =
  2605. namecoinrpcport = 8336
  2606. sendoutgoingconnections = True
  2607. daemon = true
  2608. #+END_SRC
  2609. Save and exit. Then enable the daemon and run it.
  2610. #+BEGIN_SRC: bash
  2611. rm -f /tmp/-usr-local-share-pybitmessage-*.lock
  2612. chown -R bitmsg:bitmsg /home/bitmsg
  2613. chmod +x /etc/init.d/pybitmessage
  2614. update-rc.d pybitmessage defaults
  2615. service pybitmessage start
  2616. #+END_SRC
  2617. Now open port 8444 on your internet router or firewall and direct it to the BBB.
  2618. *** Using Bitmessage
  2619. 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.
  2620. 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:
  2621. #+BEGIN_SRC: bash
  2622. cd /tmp
  2623. git clone https://github.com/Bitmessage/PyBitmessage.git
  2624. cd PyBitmessage
  2625. make install
  2626. pybitmessage
  2627. #+END_SRC
  2628. *** Connect to Email
  2629. TODO: how to connect Bitmessage to an email client.
  2630. #+BEGIN_SRC: bash
  2631. cd /tmp
  2632. wget http://freedombone.uk.to/notbit.tar.gz
  2633. #+END_SRC
  2634. Verify it.
  2635. #+BEGIN_SRC: bash
  2636. sha256sum notbit.tar.gz
  2637. 972fdc9cbb8034141282337dcd5e557bce57969ff6bd1d607da89bd93cc7bb68
  2638. #+END_SRC
  2639. Extract and install it.
  2640. #+BEGIN_SRC: bash
  2641. tar -xzvf notbit.tar.gz
  2642. cd notbit
  2643. apt-get install dh-autoreconf
  2644. ./autogen.sh --prefix=/home/myusername
  2645. make
  2646. make install
  2647. #+END_SRC
  2648. ** Overcome restrictive environments
  2649. #+BEGIN_VERSE
  2650. /Censorship reflects a society's lack of confidence in itself. It is a hallmark of an authoritarian regime./
  2651. -- Potter Stewart
  2652. #+END_VERSE
  2653. 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.
  2654. 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.
  2655. #+BEGIN_SRC: bash
  2656. apt-get install shellinabox libapache2-mod-proxy-html
  2657. #+END_SRC
  2658. Update your Apache configuration.
  2659. #+BEGIN_SRC: bash
  2660. export HOSTNAME=mydomainname.com
  2661. emacs /etc/apache2/sites-available/$HOSTNAME
  2662. #+END_SRC
  2663. Within the section which begins with *<VirtualHost *:443>* add the following, replacing /mydomainname.com/ with your domain name and /myusername/ with your username.
  2664. #+BEGIN_SRC: bash
  2665. <Location /shell>
  2666. ProxyPass http://localhost:4200/
  2667. Order allow,deny
  2668. Allow from all
  2669. AuthName "Authentication for shellinabox"
  2670. AuthUserFile /home/mydomainname.com/public_html/.htpasswd
  2671. AuthGroupFile /home/mydomainname.com/public_html/.htgroup
  2672. AuthType Basic
  2673. Require group shellinabox
  2674. Require user myusername
  2675. </Location>
  2676. #+END_SRC
  2677. 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.
  2678. #+BEGIN_SRC: bash
  2679. mkdir /home/$HOSTNAME
  2680. mkdir /home/$HOSTNAME/public_html
  2681. htpasswd -c /home/$HOSTNAME/public_html/.htpasswd myusername
  2682. #+END_SRC
  2683. Create a user group.
  2684. #+BEGIN_SRC: bash
  2685. emacs /home/$HOSTNAME/public_html/.htgroup
  2686. #+END_SRC
  2687. Add the following:
  2688. #+BEGIN_SRC: bash
  2689. shellinabox: myusername
  2690. #+END_SRC
  2691. Save and exit, then restart Apache.
  2692. #+BEGIN_SRC: bash
  2693. a2enmod proxy_http
  2694. service apache2 restart
  2695. #+END_SRC
  2696. Now with a web browser navigate to https://mydomainname.com/shell and log in.
  2697. 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/.
  2698. ** Set up a mailing list
  2699. #+BEGIN_VERSE
  2700. /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./
  2701. -- Jono Bacon
  2702. #+END_VERSE
  2703. *** With Email
  2704. 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.
  2705. **** Installation
  2706. #+BEGIN_SRC: bash
  2707. export HOSTNAME=mydomainname.com
  2708. apt-get install mailman
  2709. newlist mailman
  2710. #+END_SRC
  2711. Enter an email address for the list administrator and a password.
  2712. #+BEGIN_SRC: bash
  2713. emacs /etc/mailman/mm_cfg.py
  2714. #+END_SRC
  2715. Set *MTA=None* and change *http:* to *https:*, then save and exit.
  2716. Add some settings.
  2717. #+BEGIN_SRC: bash
  2718. emacs /etc/exim4/conf.d/main/04_mailman_options
  2719. #+END_SRC
  2720. Add the following, replacing /mydomainname.com/ with your domain name.
  2721. #+BEGIN_SRC: bash
  2722. # Mailman macro definitions
  2723. # Home dir for the Mailman installation
  2724. MM_HOME=/var/lib/mailman
  2725. # User and group for Mailman
  2726. MM_UID=list
  2727. MM_GID=list
  2728. #
  2729. # Domains that your lists are in - colon separated list
  2730. # you may wish to add these into local_domains as well
  2731. domainlist mm_domains=mydomainname.com
  2732. # The path of the Mailman mail wrapper script
  2733. MM_WRAP=MM_HOME/mail/mailman
  2734. #
  2735. # The path of the list config file (used as a required file when
  2736. # verifying list addresses)
  2737. MM_LISTCHK=MM_HOME/lists/${lc::$local_part}/config.pck
  2738. #+END_SRC
  2739. Save and exit.
  2740. #+BEGIN_SRC: bash
  2741. emacs /etc/exim4/conf.d/main/000_localmacros
  2742. #+END_SRC
  2743. Append the following:
  2744. #+BEGIN_SRC: bash
  2745. SYSTEM_ALIASES_PIPE_TRANSPORT = address_pipe
  2746. SYSTEM_ALIASES_USER = list
  2747. SYSTEM_ALIASES_GROUP = list
  2748. #+END_SRC
  2749. Save and exit.
  2750. #+BEGIN_SRC: bash
  2751. emacs /etc/exim4/conf.d/acl/30_exim4-config_check_rcpt
  2752. #+END_SRC
  2753. Append the following, before the final /accept/:
  2754. #+BEGIN_SRC: bash
  2755. # Do callback verification unless Mailman incoming bounce
  2756. deny !local_parts = *-bounces : *-bounces+*
  2757. !verify = sender/callout=30s,defer_ok
  2758. #+END_SRC
  2759. Save and exit.
  2760. #+BEGIN_SRC: bash
  2761. emacs
  2762. /etc/exim4/conf.d/router/450_mailman_aliases
  2763. #+END_SRC
  2764. Add the following:
  2765. #+BEGIN_SRC: bash
  2766. mailman_router:
  2767. driver = accept
  2768. domains = +mm_domains
  2769. require_files = MM_LISTCHK
  2770. local_part_suffix_optional
  2771. local_part_suffix = -admin : \
  2772. -bounces : -bounces+* : \
  2773. -confirm : -confirm+* : \
  2774. -join : -leave : \
  2775. -owner : -request : \
  2776. -subscribe : -unsubscribe
  2777. transport = mailman_transport
  2778. #+END_SRC
  2779. Save and exit.
  2780. #+BEGIN_SRC: bash
  2781. emacs /etc/exim4/conf.d/transport/40_mailman_pipe
  2782. #+END_SRC
  2783. Add the following:
  2784. #+BEGIN_SRC: bash
  2785. mailman_transport:
  2786. driver = pipe
  2787. command = MM_WRAP \
  2788. '${if def:local_part_suffix \
  2789. {${sg{$local_part_suffix}{-(\\w+)(\\+.*)?}{\$1}}} \
  2790. {post}}' \
  2791. $local_part
  2792. current_directory = MM_HOME
  2793. home_directory = MM_HOME
  2794. user = MM_UID
  2795. group = MM_GID
  2796. #+END_SRC
  2797. Save and exit.
  2798. #+BEGIN_SRC: bash
  2799. chown root:list /var/lib/mailman/mail/mailman
  2800. update-exim4.conf.template -r
  2801. update-exim4.conf
  2802. service exim4 restart
  2803. emacs /etc/apache2/conf.d/mailman
  2804. #+END_SRC
  2805. Add the following:
  2806. #+BEGIN_SRC: bash
  2807. Alias /pipermail /var/lib/mailman/archives/public
  2808. Alias /images/mailman /usr/share/images/mailman
  2809. <directory /var/lib/mailman/archives/public>
  2810. DirectoryIndex index.html
  2811. </directory>
  2812. #+END_SRC
  2813. Save and exit.
  2814. #+BEGIN_SRC: bash
  2815. emacs /etc/apache2/sites-available/$HOSTNAME
  2816. #+END_SRC
  2817. Add the following to the 443 section.
  2818. #+BEGIN_SRC: bash
  2819. <Location /mailman>
  2820. Options Indexes FollowSymLinks MultiViews
  2821. Order allow,deny
  2822. Allow from all
  2823. RedirectMatch ^/$ /cgi-bin/mailman/listinfo
  2824. </Location>
  2825. #+END_SRC
  2826. Save and exit.
  2827. #+BEGIN_SRC: bash
  2828. service apache2 restart
  2829. #+END_SRC
  2830. Now add your mailing list. The list name should not include any spaces.
  2831. #+BEGIN_SRC: bash
  2832. newlist mymailinglistname
  2833. #+END_SRC
  2834. With a browser visit https://$HOSTNAME/cgi-bin/mailman/admin/mymailinglistname to configure the mailing list.
  2835. Under *General Options* add an email address for a moderator (could be the same as the administrator) and click *Submit your changes*.
  2836. Under *Privacy Options* set steps required for subscription to *Confirm and approve* and click *Submit your changes*.
  2837. Also change these settings for the account within https://$HOSTNAME/cgi-bin/mailman/admin/mailman
  2838. #+BEGIN_SRC: bash
  2839. emacs /etc/aliases
  2840. #+END_SRC
  2841. Append the following, replacing /mymailinglistname/ with your mailing list name:
  2842. #+BEGIN_SRC: bash
  2843. mymailinglistname: "|/var/lib/mailman/mail/mailman post mymailinglistname"
  2844. mymailinglistname-admin: "|/var/lib/mailman/mail/mailman admin mymailinglistname"
  2845. mymailinglistname-bounces: "|/var/lib/mailman/mail/mailman bounces mymailinglistname"
  2846. mymailinglistname-confirm: "|/var/lib/mailman/mail/mailman confirm mymailinglistname"
  2847. mymailinglistname-join: "|/var/lib/mailman/mail/mailman join mymailinglistname"
  2848. mymailinglistname-leave: "|/var/lib/mailman/mail/mailman leave mymailinglistname"
  2849. mymailinglistname-owner: "|/var/lib/mailman/mail/mailman owner mymailinglistname"
  2850. mymailinglistname-request: "|/var/lib/mailman/mail/mailman request mymailinglistname"
  2851. mymailinglistname-subscribe: "|/var/lib/mailman/mail/mailman subscribe mymailinglistname"
  2852. mymailinglistname-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mymailinglistname"
  2853. #+END_SRC
  2854. Save and exit. Then to test that the mailing list works:
  2855. #+BEGIN_SRC: bash
  2856. exim -d+route -bt mymailinglistname@$HOSTNAME
  2857. #+END_SRC
  2858. If everything is working then this shouldn't show any problems.
  2859. **** Using the mailing list
  2860. Direct subscribers towards:
  2861. #+BEGIN_SRC: bash
  2862. https://mydomainname.com/cgi-bin/mailman/listinfo/mymailinglistname
  2863. #+END_SRC
  2864. To administrate the list visit:
  2865. #+BEGIN_SRC: bash
  2866. https://mydomainname.com/cgi-bin/mailman/admin/mymailinglistname
  2867. #+END_SRC
  2868. To add another mailing list:
  2869. #+BEGIN_SRC: bash
  2870. newlist mymailinglistname
  2871. #+END_SRC
  2872. To delete a mailing list:
  2873. #+BEGIN_SRC: bash
  2874. rmlist -a mymailinglistname
  2875. #+END_SRC
  2876. *** With Bitmessage
  2877. 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".
  2878. On a Debian based system:
  2879. #+BEGIN_SRC: bash
  2880. sudo apt-get install makepasswd
  2881. #+END_SRC
  2882. or on an RPM based system:
  2883. #+BEGIN_SRC: bash
  2884. sudo yum install makepasswd
  2885. #+END_SRC
  2886. Create a name for your mailing list. This will be a random string.
  2887. #+BEGIN_SRC: bash
  2888. makepasswd -c 40
  2889. #+END_SRC
  2890. Keep a note of this.
  2891. Run the Bitmessage client and on the menu select *File/Join-Create Chan/Create new chan*
  2892. 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.
  2893. 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.
  2894. 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.
  2895. 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.
  2896. ** Install Tripwire
  2897. #+BEGIN_VERSE
  2898. /...by the time you get done with all of that, we have a freedom box/
  2899. -- Eben Moglen
  2900. #+END_VERSE
  2901. 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.
  2902. #+BEGIN_SRC: bash
  2903. apt-get install tripwire
  2904. export HOSTNAME=mydomainname.com
  2905. cd /etc/tripwire
  2906. cp arm-local.key $HOSTNAME-local.key
  2907. cp site.key $HOSTNAME-site.key
  2908. tripwire --init
  2909. tripwire --update-policy --secure-mode low /etc/tripwire/twpol.txt
  2910. tripwire --check --interactive
  2911. #+END_SRC
  2912. you will be asked for two passphrases ("site" and "local"). Make a note of these.
  2913. Turn off reporting of changes to system logs.
  2914. #+BEGIN_SRC: bash
  2915. emacs /etc/tripwire/twcfg.txt
  2916. #+END_SRC
  2917. Set *SYSLOGREPORTING* to false, then save and exit.
  2918. If you subsequently install any more packages or make configuration changes then update the policy again with:
  2919. #+BEGIN_SRC: bash
  2920. tripwire --update-policy --secure-mode low /etc/tripwire/twpol.txt
  2921. #+END_SRC
  2922. Also, to look for any rootkits.
  2923. #+BEGIN_SRC: bash
  2924. apt-get install rkhunter
  2925. #+END_SRC
  2926. * Router/Firewall ports
  2927. The following ports on your internet router/firewall should be forwarded to the BBB.
  2928. | Protocol | Port/s |
  2929. |---------------+------------|
  2930. | Gopher | 70 |
  2931. | HTTP | 80 |
  2932. | HTTPS | 443 |
  2933. | IMAP | 143 |
  2934. | IRC SSL | 6670 |
  2935. | SIP | 5060..5061 |
  2936. | SMTP | 25 |
  2937. | SMTPS | 465 |
  2938. | SSH | 22 |
  2939. | XMPP | 5222..5223 |
  2940. | XMPP (server) | 5269 |
  2941. | XMPP (BOSH) | 5280..5281 |
  2942. | Bitmessage | 8444 |
  2943. * Hints and Tips
  2944. ** Messaging security
  2945. 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.
  2946. ** Moving Domains
  2947. 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:
  2948. #+BEGIN_SRC: bash
  2949. find /var/www/mynewdomain/htdocs -type f -exec sed -i 's@myolddomain@mynewdomain@g' {} \;
  2950. #+END_SRC
  2951. ** MySql foo
  2952. *** Backup all databases
  2953. To back up all mysql databases:
  2954. #+BEGIN_SRC: bash
  2955. mysqldump -u root -p --all-databases --events > /var/backups/databasebackup.sql
  2956. #+END_SRC
  2957. *** Restoring a particular mysql database
  2958. To restore yesterday's friendica backup:
  2959. #+BEGIN_SRC: bash
  2960. mysql -D friendica -o < /var/backups/friendica_daily.sql
  2961. #+END_SRC
  2962. To restore yesterday's mediawiki backup:
  2963. #+BEGIN_SRC: bash
  2964. mysql -D wikidb -o < /var/backups/wikidb_daily.sql
  2965. #+END_SRC
  2966. *** Removing mysql server
  2967. If you manage to screw up sql server completely then it can be fully deleted with:
  2968. #+BEGIN_SRC: bash
  2969. ps aux | grep mysql
  2970. #+END_SRC
  2971. and use /kill -9 <pid>/ to kill all mysql processes.
  2972. #+BEGIN_SRC: bash
  2973. apt-get remove --purge mysql\*
  2974. apt-get clean
  2975. updatedb
  2976. #+END_SRC
  2977. * Deprecated
  2978. The following items have been deprecated until such time as a successful installation is achieved.
  2979. ** Collaborative Document Editing
  2980. #+BEGIN_VERSE
  2981. /Openness and participation are antidotes to surveillance and control./
  2982. -- Howard Rheingold
  2983. #+END_VERSE
  2984. #+BEGIN_SRC: bash
  2985. apt-get install nodejs-legacy
  2986. curl https://npmjs.org/install.sh | sh
  2987. #+END_SRC
  2988. Create an etherpad database.
  2989. #+BEGIN_SRC: bash
  2990. mysql -p
  2991. CREATE DATABASE etherpad CHARACTER SET utf8 COLLATE utf8_general_ci;
  2992. GRANT ALL PRIVILEGES ON etherpad.* TO etherpad@localhost IDENTIFIED BY '__yourPasswd__';
  2993. FLUSH PRIVILEGES;
  2994. exit
  2995. #+END_SRC
  2996. Download etherpad.
  2997. #+BEGIN_SRC: bash
  2998. export HOSTNAME=mydomainname.com
  2999. cd /var/www/$HOSTNAME/htdocs
  3000. git clone git://github.com/ether/etherpad-lite.git etherpad
  3001. #+END_SRC
  3002. Edit the configuration file
  3003. #+BEGIN_SRC: bash
  3004. cd /var/www/$HOSTNAME/htdocs/etherpad
  3005. cp settings.json.template settings.json
  3006. emacs /var/www/$HOSTNAME/htdocs/etherpad/settings.json
  3007. #+END_SRC
  3008. Change the following settings. /rAnD0m5tRIng/ should be altered to a random string 10 characters in length.
  3009. #+BEGIN_SRC: bash
  3010. //IP and port which etherpad should bind at
  3011. "ip": "127.0.0.1",
  3012. // set a session key
  3013. "sessionKey" : "rAnD0m5tRIng",
  3014. //configure the connection settings
  3015. "dbType" : "mysql",
  3016. "dbSettings" : {
  3017. "user" : "etherpad",
  3018. "host" : "localhost",
  3019. "password": "__yourPassword__",
  3020. "database": "etherpad"
  3021. },
  3022. // add admin user
  3023. "users": {
  3024. "admin": {
  3025. "password": "__yourAdminPassword__",
  3026. "is_admin": true
  3027. }
  3028. },
  3029. #+END_SRC
  3030. Save and exit, then create a system user.
  3031. #+BEGIN_SRC: bash
  3032. adduser --system --home=/var/www/$HOSTNAME/htdocs/etherpad/ --group etherpad
  3033. chown -R etherpad: /var/www/$HOSTNAME/htdocs/etherpad/
  3034. #+END_SRC
  3035. Create an init script using your favorite editor.
  3036. #+BEGIN_SRC: bash
  3037. emacs /etc/init.d/etherpad
  3038. #+END_SRC
  3039. Add the following, replacing /mydomainname.com/ with your domain name:
  3040. #+BEGIN_SRC: bash
  3041. #!/bin/sh
  3042. ### BEGIN INIT INFO
  3043. # Provides: etherpad-lite
  3044. # Required-Start: $local_fs $remote_fs $network $syslog
  3045. # Required-Stop: $local_fs $remote_fs $network $syslog
  3046. # Default-Start: 2 3 4 5
  3047. # Default-Stop: 0 1 6
  3048. # Short-Description: starts etherpad lite
  3049. # Description: starts etherpad lite using start-stop-daemon
  3050. ### END INIT INFO
  3051. PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin"
  3052. LOGFILE="/var/www/mydomainname.com/htdocs/etherpad/etherpad-lite.log"
  3053. EPLITE_DIR="/var/www/mydomainname.com/htdocs/etherpad"
  3054. EPLITE_BIN="bin/safeRun.sh"
  3055. USER="etherpad"
  3056. GROUP="etherpad"
  3057. DESC="Etherpad Lite"
  3058. NAME="etherpad-lite"
  3059. set -e
  3060. . /lib/lsb/init-functions
  3061. start() {
  3062. echo "Starting $DESC... "
  3063. start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile /var/run/$NAME.pid --exec $EPLITE_DIR/$EPLITE_BIN -- $LOGFILE || true
  3064. echo "done"
  3065. }
  3066. #We need this function to ensure the whole process tree will be killed
  3067. killtree() {
  3068. local _pid=$1
  3069. local _sig=${2-TERM}
  3070. for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
  3071. killtree ${_child} ${_sig}
  3072. done
  3073. kill -${_sig} ${_pid}
  3074. }
  3075. stop() {
  3076. echo "Stopping $DESC... "
  3077. while test -d /proc/$(cat /var/run/$NAME.pid); do
  3078. killtree $(cat /var/run/$NAME.pid) 15
  3079. sleep 0.5
  3080. done
  3081. rm /var/run/$NAME.pid
  3082. echo "done"
  3083. }
  3084. status() {
  3085. status_of_proc -p /var/run/$NAME.pid "" "etherpad-lite" && exit 0 || exit $?
  3086. }
  3087. case "$1" in
  3088. start)
  3089. start
  3090. ;;
  3091. stop)
  3092. stop
  3093. ;;
  3094. restart)
  3095. stop
  3096. start
  3097. ;;
  3098. status)
  3099. status
  3100. ;;
  3101. *)
  3102. echo "Usage: $NAME {start|stop|restart|status}" >&2
  3103. exit 1
  3104. ;;
  3105. esac
  3106. exit 0
  3107. #+END_SRC
  3108. Save and exit, then enable the daemon.
  3109. #+BEGIN_SRC: bash
  3110. chmod +x /etc/init.d/etherpad
  3111. update-rc.d etherpad defaults
  3112. service etherpad start
  3113. #+END_SRC
  3114. Update your Apache configuration.
  3115. #+BEGIN_SRC: bash
  3116. emacs /etc/apache2/sites-available/$HOSTNAME
  3117. #+END_SRC
  3118. Within the section which begins with *<VirtualHost *:443>* add the following:
  3119. #+BEGIN_SRC: bash
  3120. <Location /etherpad>
  3121. ProxyPass http://localhost:9001/
  3122. ProxyPassReverse http://localhost:9001/
  3123. Order allow,deny
  3124. allow from all
  3125. AuthName "Welcome to Etherpad"
  3126. AuthUserFile /home/mydomainname.com/public_html/.htpasswd
  3127. AuthGroupFile /home/mydomainname.com/public_html/.htgroup
  3128. AuthType Basic
  3129. Require group etherpad
  3130. </Location>
  3131. #+END_SRC
  3132. Save and exit, then restart Apache.
  3133. #+BEGIN_SRC: bash
  3134. apt-get install libapache2-mod-proxy-html
  3135. a2enmod proxy proxy_http headers deflate
  3136. service apache2 restart
  3137. #+END_SRC
  3138. Create some passwords for users.
  3139. #+BEGIN_SRC: bash
  3140. mkdir /home/$HOSTNAME
  3141. mkdir /home/$HOSTNAME/public_html
  3142. htpasswd -c /home/$HOSTNAME/public_html/.htpasswd myusername
  3143. #+END_SRC
  3144. Create a user group.
  3145. #+BEGIN_SRC: bash
  3146. emacs /home/$HOSTNAME/public_html/.htgroup
  3147. #+END_SRC
  3148. Add the following:
  3149. #+BEGIN_SRC: bash
  3150. etherpad: myusername
  3151. #+END_SRC
  3152. Save and exit.
  3153. ** Install a VoIP server
  3154. #+BEGIN_VERSE
  3155. /Our core principles, whether in software or sovereignty, have always been about freedom and dignity, for all people, on an equal basis/
  3156. -- David Sugar, GNU Telephony
  3157. #+END_VERSE
  3158. *** The server
  3159. 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.
  3160. Edit your package sources:
  3161. #+BEGIN_SRC: bash
  3162. emacs /etc/apt/sources.list
  3163. #+END_SRC
  3164. Append the following line:
  3165. #+BEGIN_SRC: bash
  3166. deb http://dev.gnutelephony.org/archive/ wheezy/
  3167. #+END_SRC
  3168. Save and exit.
  3169. 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
  3170. #+BEGIN_SRC: bash
  3171. apt-get install gnutelephony-keyring
  3172. #+END_SRC
  3173. After that it will be happy to accept it as a signed repository. The verification keys can also be directly fetched with
  3174. #+BEGIN_SRC: bash
  3175. cd /tmp
  3176. wget http://dev.gnutelephony.org/archive/wheezy/public.key
  3177. #+END_SRC
  3178. and manually added instead with
  3179. #+BEGIN_SRC: bash
  3180. apt-key add public.key
  3181. #+END_SRC
  3182. To make sure you have all dependencies, do
  3183. #+BEGIN_SRC: bash
  3184. apt-get update;apt-get dist-upgrade
  3185. #+END_SRC
  3186. Before we install anything, let's inspect what is available to us by using
  3187. #+BEGIN_SRC: bash
  3188. dpkg -l sipwitch
  3189. #+END_SRC
  3190. To see the main application. The columns will indicate if the package is installed, which version and a description of the package. Then do
  3191. #+BEGIN_SRC: bash
  3192. dpkg -l sipwitch-*
  3193. #+END_SRC
  3194. 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.
  3195. To install only the main application, do
  3196. #+BEGIN_SRC: bash
  3197. apt-get install sipwitch
  3198. #+END_SRC
  3199. and to install all supporting plugins:
  3200. #+BEGIN_SRC: bash
  3201. apt-get install sipwitch-plugin-scripting sipwitch-plugin-subscriber sipwitch-plugin-forward sipwitch-plugin-zeroconf
  3202. #+END_SRC
  3203. Add your user into the sipwitch group
  3204. #+BEGIN_SRC: bash
  3205. groupadd sipwitch
  3206. groupadd sipusers
  3207. usermod -aG sipwitch myusername
  3208. usermod -aG sipusers myusername
  3209. #+END_SRC
  3210. Then edit the configuration
  3211. #+BEGIN_SRC: bash
  3212. emacs /etc/sipwitch.conf
  3213. #+END_SRC
  3214. Change the *mapped* value from 200 to 20, since we don't want to be serving huge numbers of calls.
  3215. 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.
  3216. Do not set the *realm* value, as doing so seems to prevent the server from working.
  3217. Save and exit.
  3218. Create a digest string for your username:
  3219. #+BEGIN_SRC: bash
  3220. sipwitch digest myusername
  3221. #+END_SRC
  3222. Make a note of the resulting string because you're going to use it in the users file you'll now create.
  3223. #+BEGIN_SRC: bash
  3224. export HOSTNAME=mydomainname.com
  3225. touch /etc/sipwitch.d/$HOSTNAME.xml
  3226. chmod 600 /etc/sipwitch.d/$HOSTNAME.xml
  3227. emacs /etc/sipwitch.d/$HOSTNAME.xml
  3228. #+END_SRC
  3229. It should look something like the following:
  3230. #+BEGIN_SRC: bash
  3231. <provision>
  3232. <user id="myusername">
  3233. <digest>yourdigeststring</digest>
  3234. <extension>201</extension>
  3235. <display>Your full name</display>
  3236. </user>
  3237. </provision>
  3238. #+END_SRC
  3239. Save and exit. Now edit the configuration.
  3240. #+BEGIN_SRC: bash
  3241. emacs /etc/default/sipwitch
  3242. #+END_SRC
  3243. Change "desktop" to "server", then save and exit.
  3244. Update the IP settings:
  3245. #+BEGIN_SRC: bash
  3246. iptables -A INPUT -p tcp --dport 5060 -j ACCEPT
  3247. iptables -A INPUT -p udp --dport 5060 -j ACCEPT
  3248. iptables -A INPUT -p tcp --dport 5061 -j ACCEPT
  3249. iptables -A INPUT -p udp --dport 5061 -j ACCEPT
  3250. iptables-save
  3251. #+END_SRC
  3252. Test that it's working:
  3253. #+BEGIN_SRC: bash
  3254. pkill -9 sipw
  3255. sipw -x9 -f
  3256. #+END_SRC
  3257. 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.
  3258. #+BEGIN_SRC: bash
  3259. service sipwitch start
  3260. #+END_SRC
  3261. *** Clients
  3262. **** Jitsi
  3263. Download the latst version from https://jitsi.org/index.php/Main/Download
  3264. TODO
  3265. **** Twinkle client
  3266. The client should have a user profile as following:
  3267. The "user name" is the xxx id used in the <user id="xxx"> entry of /etc/sipwitch.conf
  3268. The "domain" is the yyy domain in the main config <stack><domain>yyy entry of /etc/sipwitch.conf
  3269. The SIP Authentication should have:
  3270. realm = realm as set in <registry><realm> of /etc/sipwitch.conf
  3271. authentication name = <user id="xx"> entry, same as "User Name" field.
  3272. password = value of <secret>zzz in <user> entry of /etc/sipwitch.conf
  3273. Under security tab, set "Enable ZRTP/SRTP encryption"
  3274. **** Android
  3275. TODO
  3276. CSipSimple?
  3277. ** Install Mediagoblin
  3278. #+BEGIN_SRC: bash
  3279. apt-get install git-core python python-dev python-lxml python-imaging python-virtualenv apache2-suexec libapache2-mod-fcgid
  3280. #+END_SRC
  3281. #+BEGIN_SRC: bash
  3282. adduser --system mediagoblin
  3283. addgroup mediagoblin
  3284. adduser mediagoblin mediagoblin
  3285. export HOSTNAME=mydomainname.com
  3286. cd /var/www/$HOSTNAME/htdocs
  3287. git clone git://gitorious.org/mediagoblin/mediagoblin.git mediagoblin
  3288. chown -hR mediagoblin:mediagoblin /var/www/$HOSTNAME/htdocs/mediagoblin
  3289. cd /var/www/$HOSTNAME/htdocs/mediagoblin
  3290. git submodule init && git submodule update
  3291. cp mediagoblin.ini mediagoblin_local.ini
  3292. emacs mediagoblin.ini
  3293. #+END_SRC
  3294. Set email_sender_address to the address you wish to be used as the sender for system-generated emails
  3295. Edit direct_remote_path, base_dir, and base_url if your mediagoblin directory is not the root directory of your vhost.
  3296. Save and exit.
  3297. #+BEGIN_SRC: bash
  3298. a2enmod suexec
  3299. a2enmod fcgid
  3300. emacs /etc/apache2/sites-available/$HOSTNAME
  3301. #+END_SRC
  3302. Add the following to the 80 virtual host, replacing mydomainname.com with your domain name.
  3303. #+BEGIN_SRC: bash
  3304. <Directory /var/www/mydomainname.com/htdocs/mediagoblin>
  3305. deny from all
  3306. </Directory>
  3307. #+END_SRC
  3308. Add the following to the 443 virtual host.
  3309. #+BEGIN_SRC: bash
  3310. # Serve static and media files via alias
  3311. Alias /mgoblin_static/ /var/www/mydomainname.com/htdocs/mediagoblin/mediagoblin/static/
  3312. Alias /mgoblin_media/ /var/www/mydomainname.com/htdocs/mediagoblin/user_dev/media/public/
  3313. # Rewrite all URLs to fcgi, except for static and media urls
  3314. RewriteEngine On
  3315. RewriteRule ^(mgoblin_static|mgoblin_media)($|/) - [L]
  3316. RewriteCond %{REQUEST_FILENAME} !-f
  3317. RewriteRule ^/(.*)$ /mg.fcgi/$1 [QSA,L]
  3318. # Allow access to static and media directories
  3319. <Directory /var/www/mydomainname.com/htdocs/mediagoblin/mediagoblin/static>
  3320. Order allow,deny
  3321. Allow from all
  3322. </Directory>
  3323. <Directory /var/www/mydomainname.com/htdocs/mediagoblin/mediagoblin/user_dev/media/public>
  3324. Order allow,deny
  3325. Allow from all
  3326. </Directory>
  3327. # Connect to fcgi server
  3328. FastCGIExternalServer /var/www/mg.fcgi -host 127.0.0.1:26543
  3329. #+END_SRC
  3330. Save and exit
  3331. #+BEGIN_SRC: bash
  3332. cd /var/www/$HOSTNAME/htdocs/mediagoblin
  3333. ./lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543
  3334. #+END_SRC
  3335. https://github.com/joar/mediagoblin-init-scripts
  3336. ** Kune
  3337. 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).
  3338. #+BEGIN_SRC: bash
  3339. apt-get install openjdk-6-jdk openjdk-7-jre mysql-server adduser dbconfig-common libjmagick6-jni
  3340. #+END_SRC
  3341. Add the Kune repository:
  3342. #+BEGIN_SRC: bash
  3343. emacs /etc/apt/sources.list
  3344. #+END_SRC
  3345. Append the following:
  3346. #+BEGIN_SRC: bash
  3347. deb ftp://ftp.kune.ourproject.org/pub/kune/debian/ stable/
  3348. #+END_SRC
  3349. Save and exit, then install the Kune package.
  3350. #+BEGIN_SRC: bash
  3351. gpg --keyserver pgp.mit.edu --recv-keys 9E358A05
  3352. gpg --armor --export 9E358A05 | apt-key add -
  3353. apt-get update
  3354. apt-get install kune
  3355. #+END_SRC
  3356. You will be asked for the MySql root password and another password to be used with the Kune database.
  3357. Allow the system to start automatically at boot.
  3358. #+BEGIN_SRC: bash
  3359. emacs /etc/default/kune
  3360. #+END_SRC
  3361. Set /START=yes/, then save and exit.
  3362. #+BEGIN_SRC: bash
  3363. service kune start
  3364. #+END_SRC
  3365. Now configure Apache.
  3366. #+BEGIN_SRC: bash
  3367. a2enmod expires
  3368. a2enmod proxy
  3369. a2enmod proxy_connect
  3370. a2enmod proxy_http
  3371. #+END_SRC
  3372. Upgrade the database.
  3373. #+BEGIN_SRC: bash
  3374. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.1.0+b5
  3375. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.1.0+b6
  3376. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.2.0+b12
  3377. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.2.0+b23
  3378. mysql -p kune_prod < /usr/share/dbconfig-common/data/kune/upgrade/mysql/0.2.0+b25
  3379. #+END_SRC
  3380. Edit the Apache configuration.
  3381. #+BEGIN_SRC: bash
  3382. emacs /etc/apache2/sites-available/$HOSTNAME
  3383. #+END_SRC
  3384. <VirtualHost *:80>
  3385. ServerName YOURSERVERNAME
  3386. ProxyRequests Off
  3387. <Proxy *>
  3388. Order deny,allow
  3389. Allow from all
  3390. </Proxy>
  3391. <Files *.cache.*>
  3392. ExpiresActive On
  3393. ExpiresDefault "modification plus 2 years"
  3394. </Files>
  3395. <Files *.nocache.*>
  3396. ExpiresActive Off
  3397. </Files>
  3398. ProxyPass /kune/ http://localhost:8888/
  3399. ProxyPassReverse /kune/ http://localhost:8888/
  3400. <Location /var/www/mydomainname.com/htdocs/kune/>
  3401. Order allow,deny
  3402. Allow from all
  3403. </Location>
  3404. </VirtualHost>
  3405. Within a browser open https://mydomainname.com:8888
  3406. See documentation in /usr/share/doc/kune/INSTALL.gz
  3407. * Related projects
  3408. * [[https://freedomboxfoundation.org/][Freedombox]]
  3409. * [[https://arkos.io/][ArkOS]]