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
- Change password for user “customer”
- Add my ssh pubkey for user root
- Install Tailscale
- Set hostname with
hostnamectl set-hostname - Add DNS A records to
somebits.comfor both main IP and Tailscale IP - Run
apt upgrade - 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 adduser nelsonusermod -aG adm,cdrom,sudo,dip,plugdev,lxd nelson- reboot
- file a ticket for reverse DNS
- Copy all my old server files from backup to a subdirectory under
/root - Set up
/home/nelsonfrom the backup - Set up
rsnapshotbackups. This is very fiddly;rsnapshot -tis 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. apt install mailand set up a local-only postfix- Skipping this time: autossh, munin
Service specific stuff
- Change
*.somebits.comandsomebits.comDNS to new server. I did this early, before the new server was fully set up, because the old one was already broken. - Change DNS entries for other services I run (check Hover DNS).
apt install apache2- Copy over
/var/wwwfrom the backup - apt install certbot python3-certbot-apache
- Restore
/usr/local/etcfrom backup - Restore
/etc/apache2from backup - Make subdirectories in
/var/log/apache2for d in logsoflag n177xy somebits weblog windhistory; do mkdir $d; done - Restore
/etc/logrotate.dentries that are relevant - Set up Perl environment for Blosxom
apt install libcgi-pm-perl libimage-size-perl - Migrate old Let’s Encrypt install over to new server
Restore/etc/letsencryptfrom backup
Test https works on new server (beware of DNS expiration times)
Test certbot renewal withcertbot renew --dry-run
Remind yourself to check in three months - Copy over and test secret stuff from
/usr/lib/cgi-bin(no, really!) Also requiresapt install python2 - 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. - User crontabs in
/var/spool/cron/crontabs.
Testing
- Look at
dmesgand/var/log/syslogfor anything troubling - Try various websites
- Look at
/var/log/apache2/*/error.logfor anything troubling - 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.