Friday, June 15, 2018

Debian 9 Build Guide

I decided to upgrade my Linode VM from 1 GB RAM/$5 per-month to the 2 GB RAM/$10 per-month offering - life is too short to faff around trying to get a modern distro with GUI and browser to work in 1 GB RAM.  I also decided to rebuild with Debian 9 to compare steps to Centos 7.

Update
$ apt-get update && apt-get upgrade

Change SSH port:
# vi /etc/ssh/sshd_config
Uncomment and change default port 22
# service sshd restart
Reboot and test
# reboot
Windows (Start -> Run or Windows key + R):
putty user@host -P 2222

Disable SSH root access
# adduser normalusername
# echo 'normalusername ALL=(ALL) ALL' >> /etc/sudoers
Test!!!  Skip testing at your own peril.
putty normalusername@host -P 2222
$ sudo su -
should succeed and get you to the # root prompt
# vi /etc/ssh/sshd_config
Edit line
PermitRootLogin yes
to
PermitRootLogin no
# service sshd restart












Install GUI
# tasksel
follow prompts, selected Xfce - hopefully better luck here than on the CentOS VM...

Enable remote access
# apt install -y xrdp tigervnc-standalone-server
# systemctl enable xrdp

And now I'm going to take a quick break, because apparently due to "Nautilus" I can't change the xfce desktop backgroup to something more friendly to a remote session.  


and for remote access
# yum install xrdp
# service xrdp start
# systemctl enable xrdp

CentOS 7 Remote Access / RDP / VNC

I recently signed up for a small hosted server with the friendly folks over at Linode.  For $5 per month, you can't really go wrong (1 GB RAM, 25 GB storage and 1 TB monthly transfer).  I opted for a Centos7 VM and was quite quickly up and running.  I created a DNS alias at FreeDNS as I kept forgetting my VM's IP.

I also configured SSH to use a non-standard port, as /var/log/secure was showing constant attempted logins from some overly friendly IP's in China.  I also blocked a couple of the most prevalent IP's.  I disabled the ability for root to directly ssh, opting to rather login as my "normal" user and sudo as required, to add another level of protection.

One bit I struggled with was remote GUI access, as I wanted this to be a general purpose box (followed Gnome install guide here).  I'm currently testing the third method on this page (XRDP) - it seems to have been the quickest to get up and running, but thus far is glacially slow - will udpate if I find a fix.  Might help somebody else in a pinch.  XRDP installation:

# yum -y install epel-release
# yum -y install xrdp
# systemctl start xrdp.service
# systemctl enable xrdp.service


UPDATE: Durrrr, modern Gnome and only 1 GB RAM do  not good bedfellows make - reverted Gnome install with:

# yum groupremove "GNOME Desktop" "Graphical Administration Tools"

And courtesy of this guide over at rootuesrs.com, installed Xfce:

# yum install epel-release -y
# yum groupinstall "Server with GUI" -y
# systemctl get-default
If not graphical.target
# systemctl set-default graphical.target

Something broke (XRDP VNC startup error), had to uninstall xrdp and then re-install VNC and xrdp:
# yum remove xrdp tightvncserver
# yum install tightvncserver
# yum install xrdp
# systemctl start xrdp.service
# systemctl enable xrdp.service
# reboot

And more woes, once RDP'd in - no menu bar or window controls:
Right-click on desktop and select Terminal - update this once proper fix found
$ xfce4-panel
$ xfwm4
Useful:
$ xfce4-settings-manager

Thursday, June 14, 2018

Bad Sleeper Diaries - Day 1

It is quite possible that I have been exhausted for the past twenty years, and have just learned to accept it as a state of being.  After several attempts at figuring out why I seldom (if ever) felt great, could never concentrate and was always sleepy, I might finally have stumbled upon the cause and - hopefully - the treatment.  It has taken a while to get here.  In my quest to figure out why, an initial diagnosis of ADHD from a psychiatrist and associated Ritalin treatment in my early thirties just gave me hyper focus and made me chatter away like a coked up marketing executive (pleasant but not helpful).

Subsequently, seeing an ENT and having a tonsillectomy and septoplasty to clear my airways made a small improvement (this was when I first began to suspect sleep issues - mid-thirties).  More importantly the doctor's stern warning to lose weight stuck with me, and by following a strict low carb/no alcohol diet with daily walking I was able to lose almost 30 kg's (66 lbs) over a 3- or 4-month period.  For a while, I was feeling good, losing weight, getting things done and living a healthy lifestyle.  For the first time in a long time I was happy with the way I looked in photos.

Sadly, life got in the way - the stresses of a poorly planned home renovation and new relationship led to me abandoning the diet and daily exercise, and over time I ballooned to my heaviest weight ever (currently 133 kg / 293 lbs).  The few years in-between then and now have certainly been eventual, with as many ups as downs - I sold the renovated house, bought a new one, my beautiful son arrived, I lost my mother to suicide, had to undergo a massive amount of stress to settle her estate, bought a new car, was able to settle all my debts (after many years of struggle) and after a rather stormy period separated from my son's mother (although we still live together and now get along quite well).

So I recently found myself, finally in a time of relative stability, and starting to get really frustrated.  Angry at myself for being overweight but also feeling despair that all my attempts at getting in shape failed.  Admittedly, some attempts were more determined than others, but it always seemed to fall apart after a few days.  I've been at this long enough to know to forgive myself and try to keep at it, but I would subconsciously drift back into normal patterns - I'd be genuinely surprised that weeks had passed since my last walk, as an example.

My thoughts feel like there are drunk spider monkeys controlling my brain, always running at high speed tangents, I find myself always going into a room and forgetting why I'm there, or unable to mentally sequence the simplest of tasks.  So in desperation I recently reached out to my ENT doc via email, explained that I'm now overweight and having great difficulty getting it under control (vicious circle of weight gain and low energy) and wanted to try out a CPAP machine to see if my broken sleep was the cause of my woes.  I've been told I snore badly for years, and when I sleep with somebody they tell me that my gasping during the night is quite disturbing.

I was excited to try this solution, but also knew that there would some hoops to jump through first.  The first of these was a "sleep lab", whereby I nervously spent a night in a nearby hospital with very many probes and sensors connected to me whilst they monitored my sleep.  I was worried about falling asleep under those conditions, but in my permanently exhausted state I was out like a light.  For the benefit of anybody else reading this with a similar condition, I'll add the detailed results of the sleep lab later - I recall my AHI was over 95 (apnea index - breathing obstructions per hour).  In addition, over 700 arousal events were recorded during my session.  All these number I need to learn to understand in detail as I go down this road.

A few days later, I was provided with a loan CPAP (Airsense 10 auto) from the sleep lab's office.  They showed me how to use it and allowed me two nights to test the machine.  The first morning after using the machine was an absolute revelation - I woke up feeling refreshed and with a sense of mental clarity I don't recall having ever experienced.  I simply felt calm and able to string thoughts together without difficulty.  I could get things done with such ease - as if the spider monkeys had sobered up and actually had a conductor orchestrating their actions.  During the night itself, I could only recollect waking up once (normally 2 or 3 times) - I was aware of the full face mask I was using but it wasn't too uncomfortable.

The second night did unfortunately not go so well and I didn't feel much different to normal waking up.  On this night I started out with the smaller nasal mask, but changed back to the full facial mask during the night.  Both masks seemed to leak quite badly during the night as well.  I did have realistic expectations, so whilst it would have been good to have a second night as good as the first, I'm fairly sure it will take a month or so to adjust fully.

Fast forward to the day before yesterday, and I reached out to the ENT doc's offices to quote me on my own CPAP machine.  I had been considering a used unit, but considering the price and importance of the machine would rather pay the premium for something dependable.  I was still a bit shocked when I got the quote of almost R15,000 (~USD1250) for the machine (same as the one I trialled) and full-face mask.  However, after a few minutes consideration I'd issued the payment.  I was very excited to go and collect it at the doctor's offices, where I underwent about an hour's worth of usage instructions and mask fitting.

I'm pleased to report that this morning I feel ... quite good.  Certainly not quite the wonderful sense I had after that first night, but I suspect this maybe due to having had a bottle of wine last night - this left me with a hint of a headache this morning.  I do feel better able to concentrate - I wouldn't normally be able to write anything like this without great difficulty.  I do still have a slight sense that the spider monkeys have been drinking, but it is reduced.  I woke up once or twice during the night to adjust my mask, but didn't have any major difficulties.  I'm looking forward to see how the day goes, and can't wait to complete my adjustment to this treatment.