Some Bits: Nelson's log

Yet another new datacenter server

My server for somebits.com broke (hardware failure). My notes from last time I set this up were helpful so I’m taking boring detailed notes again.

I really need to stop having a custom configured bespoke server like this. It’s almost entirely used for web traffic these days, and most of that is static. If I can ever successfully convert my blog over to a static generator I could be done with needing a custom server.

Fairly generic stuff

  1. Change password for user “customer”
  2. Add my ssh pubkey for user root
  3. Install Tailscale
  4. Set hostname with hostnamectl set-hostname
  5. Add DNS A records to somebits.com for both main IP and Tailscale IP
  6. Run apt upgrade
  7. Install a bunch of useful packages
    apt install joe stress-ng stress s-tui smartmontools zip unzip rsync openssl webp plocate ripgrep pigz python3 python-is-python3 python3-venv python3-dev pkg-config build-essential sqlite3 chrony rsnapshot
  8. adduser nelson
  9. usermod -aG adm,cdrom,sudo,dip,plugdev,lxd nelson
  10. reboot
  11. file a ticket for reverse DNS
  12. Copy all my old server files from backup to a subdirectory under /root
  13. Set up /home/nelson from the backup
  14. Set up rsnapshot backups. This is very fiddly; rsnapshot -t is useful for testing things. On the newly installed server to be backed up it requires a new user and an entry in /etc/sudoers.d.
  15. apt install mail and set up a local-only postfix
  16. Skipping this time: autossh, munin

Service specific stuff

  1. Change *.somebits.com and somebits.com DNS to new server. I did this early, before the new server was fully set up, because the old one was already broken.
  2. Change DNS entries for other services I run (check Hover DNS).
  3. apt install apache2
  4. Copy over /var/www from the backup
  5. apt install certbot python3-certbot-apache
  6. Restore /usr/local/etc from backup
  7. Restore /etc/apache2 from backup
  8. Make subdirectories in /var/log/apache2
    for d in logsoflag n177xy somebits weblog windhistory; do mkdir $d; done
  9. Restore /etc/logrotate.d entries that are relevant
  10. Set up Perl environment for Blosxom
    apt install libcgi-pm-perl libimage-size-perl
  11. Migrate old Let’s Encrypt install over to new server
    Restore /etc/letsencrypt from backup
    Test https works on new server (beware of DNS expiration times)
    Test certbot renewal with certbot renew --dry-run
    Remind yourself to check in three months
  12. Copy over and test secret stuff from /usr/lib/cgi-bin (no, really!) Also requires
    apt install python2
  13. Set up linkblog user and test it
    adduser linkblog
    restore ~linkblog from backup
    On home server: /home/nelson/somebits/linkblog/prod/update.sh -p -f
    Probably have to swizzle cached ssh keys with this.
  14. User crontabs in /var/spool/cron/crontabs.

Testing

  1. Look at dmesg and /var/log/syslog for anything troubling
  2. Try various websites
  3. Look at /var/log/apache2/*/error.log for anything troubling
  4. Add a new linkblog entry, verify it shows up

One hidden gotcha is all the other client hosts that might have the wrong entry in .ssh/known_hosts for the domain name for the new server. You have to run ssh-keygen -f "/home/nelson/.ssh/known_hosts" -R "somebits.com" to remove them, then manually accept the new ones once.

I managed to break my first attempt at setting up the new server by adding a disk to /etc/fstab forgetting an earlier lesson. Linux systems won’t boot if something in /etc/fstab isn’t working! Fortunately the datacenter has automated system reimaging so I could start over without wasting anyone else’s time.