beaglebone.txt 130KB

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