Ubuntu 18.04 Bionic Beaver.
Add a new user who isn't root, but who can sudo:
- Update all the things:
apt-get update && apt-get dist-upgrade && apt-get autoremove
- Reboot, just in case:
shutdown -r now
- Delete the perplexing plaintext root password file:
rm /root/.pw
- Change the root password to a STRONG password:
passwd
- Add a user rather than working as root:
adduser foo
- Give them a nice strong password.
usermod -aG sudo foo
- Login as the new user:
su - foo
- Setup the
authorized_keys
for the new user. From your local machine:ssh-keygen -o -a 100 -t ed25519
- Copy the public key into the
authorized_keys
- Check that you can login as the new user from your local machine.
- The rest of the guide assume you have logged in as the user you created above.
- Secure the sshd config:
sudo nano /etc/ssh/sshd_config
Port 22
=>Port <something random above 1024>
PermitRootLogin without-password
=>PermitRootLogin no
ChallengeResponseAuthentication yes
=>ChallengeResponseAuthentication no
#PasswordAuthentication yes
=>PasswordAuthentication no
- Save and exit
- Restart sshd:
sudo service ssh restart
- BEFORE LOGING OUT OF THE CURRENT SESSION: check you can log in from your local machine with the new settings.
- Install postfix for local mail:
sudo apt-get install mailutils postfix
- Select local only configuration
- Send a test mail:
echo 'Test message' | mail -s 'This is a test message' root
- Install mutt for reading the mail:
sudo apt-get install mutt
- Check the test mail was delivered:
sudo mutt
- Install archivemail so that we can regularly archive all the cron mails we'll now get:
sudo apt-get install archivemail
- Test archive mail works:
sudo /usr/bin/archivemail -nd 28 /var/mail/root
- Install it as a cron job:
sudo crontab -e
@daily /usr/bin/archivemail -d 28 /var/mail/root
- Test archive mail works:
- Install a firewall:
sudo apt-get install ufw
- The next instructions are from: https://community.online.net/t/how-to-configures-iptables-with-input-rules-with-dynamic-nbd/303/22
sudo nano /etc/default/ufw
- Set the default INPUT policy to ACCEPT:
DEFAULT_INPUT_POLICY="ACCEPT"
- Set the default INPUT policy to ACCEPT:
- Append a drop-all rule to the INPUT chain:
sudo nano /etc/ufw/after.rules
, add this line just before the final COMMIT line:-A ufw-reject-input -j DROP
- Disable UFW logging (this seems to cause issuses with Scaleway's default kernel):
sudo ufw logging off
- Allow OpenSSH access:
sudo ufw allow <the new SSH port number you set above>
- Enable the firewall:
sudo ufw enable
Based on https://docs.ghost.org/docs/install
- Make sure everything is up to date:
sudo apt-get update && sudo apt-get upgrade
- Add the tools to add PPAs, if not already there:
sudo apt-get install software-properties-common
- Install nginx:
sudo apt-get install nginx
- Allow nginx through the firewall:
sudo ufw allow 'Nginx Full'
- Disable the default nginx website:
sudo rm /etc/nginx/sites-enabled/default
sudo nginx -s reload
- Install MySQL:
sudo apt-get install mysql-server
- Use a strong root password
- Add the nodesource apt repo:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash
- Install node:
sudo apt-get install nodejs
- Install ghost-cli:
sudo npm i -g ghost-cli
- Create the base documents folder:
sudo mkdir -p /var/www/ghost
- Chown it:
sudo chown foo:foo /var/www/ghost
- Move to that folder:
cd /var/www/ghost
- Install ghost:
ghost install
- Full guide to the installer questions: https://docs.ghost.org/docs/cli-install#section-prompts
Backups are important, m'kay? I like to use tarsnap because it can be set up in such a way that you can lose control of your server but the backups remain unreadable to the intruder.
- TODO