I am running the following version of GNU/Linux Debian:
cat /etc/issue
says:
Debian GNU/Linux 9
Using the following kernel:
uname -r
says:
4.9.0-2-amd64
And running the following version of OpenSSH:
apt-cache policy openssh-server | grep Installed
says:
Installed: 1:7.4p1-7
My intention is to harden a little one server's SSH security, since I need to have access from any IP, even from any VPN.
These steps I have done so far:
Disabling direct root access:
cat /etc/ssh/sshd_config | grep PermitRootLogin
is set to:
PermitRootLogin no
Enforcing SSH protocol version 2:
cat /etc/ssh/sshd_config | grep Protocol
is set to:
Protocol 2
Changed port to a random one, which I will not write here, so say 12345:
cat /etc/ssh/sshd_config | grep Port
is set to:
Port 12345
I have punched hole in firewall for it:
sudo iptables -A INPUT -p tcp -m tcp --dport 12345 -m comment --comment "ssh" -j ACCEPT
I have generated a new key of 8 kilobits length (I am aware of the CPU overhead and other disadvantages of such a large key):
ssh-keygen -t rsa -b 8192
I have then verified the size matches:
ll /home/fictional_user/.ssh/id_rsa*
is as it should be, as well as the access rights:
-rw------- 1 fictional_user fictional_group 6.3K Mar 16 11:53 /home/fictional_user/.ssh/id_rsa -rw-r--r-- 1 fictional_user fictional_group 1.4K Mar 16 11:53 /home/fictional_user/.ssh/id_rsa.pub
I have added this key and verified there is no other:
eval $(ssh-agent -s) ssh-add ssh-add -l
results in:
8192 SHA256:gibberish /home/fictional_user/.ssh/id_rsa (RSA) 8192 SHA256:gibberish fictional_user@fictional_computer (RSA)
I have imported the key to two machines, which will be maintaining the server:
ssh-copy-id fictional_user@public_ip -p 12345
Afterwards, I have disabled password authentication completely:
cat /etc/ssh/sshd_config | grep PasswordAuthentication
is set to:
PasswordAuthentication no
Question: Did I forget on anything or this is maximum I can do?