Ubuntu Server Setup

These are the default steps I take to setup a new Ubuntu 20.04 server.

Add User

adduser jj
usermod -aG sudo jj
sudo su - jj

Add Public Key

mkdir ~/.ssh
vim ~/.ssh/authorized_keys
# Copy paste public key saved in computer's ~/.ssh/id_rsa.pub

Edit SSH Login

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original

sudo vim /etc/ssh/sshd_config
  • Port 2222
  • ChallengeResponseAuthentication no
  • UsePAM no
  • PasswordAuthentication no
  • PermitRootLogin no
  • PermitRootLogin prohibit-password
sudo systemctl reload sshd

Update UFW

sudo ufw allow 2222
sudo ufw deny 22
sudo ufw reload
sudo ufw status

Add Alias to Local Computer

sudo vim ~/.zshrc
alias yosite="ssh -p2222 xxx@<IP-ADDRESS>
source ~/.zshrc