Log into your server as
apt-get update apt-get upgrade
Change your password. A strong password is recommended.
In my case, I created an "deploy" user.
usermod -a -G sudo deploy
Generate SSH keys on your local computer.
Make home and ssh directories for the new user.
mkdir /home/deploy mkdir /home/deploy/.ssh chmod 700 /home/deploy/.ssh
Upload your public key to your server.
scp ~/.ssh/id_rsa.pub deploy@your-server-ip-address:
Move the public key to
mv id_rsa.pub /home/deply/.ssh/authorized_keys
Modify permissions of ssh keys.
chmod 400 /home/deploy/.ssh/authorized_keys chown deploy:deploy /home/deploy -R
Change the values below.
PermitRootLogin no PasswordAuthentication no AllowUsers newUserName
Restart SSH service.
services ssh restart
apt-get install fail2ban
ufw, a front end for
iptables, to configure our fire wall.
ufw allow ssh ufw allow http ufw allow https ufw enable
ufw status verbose to show status. You can also find what has happened to iptables by typing the following command.