# open the ssh configuration file
sudo vi /etc/ssh/sshd_config
Make the following changes to /etc/ssh/sshd_config
:
# disable password authentication
PasswordAuthentication no
# disable root login
PermitRootLogin no
# limit login to users to 'ssh' group
AllowGroups ssh
# disable hostname lookup
UseDNS no
Save and exit, then reload ssh service:
sudo reload ssh
Adding new user:
adduser --shell /bin/bash --ingroup ssh username
Adding existing user to ssh
group:
usermod -a -G ssh username
Ensure permissions are correct:
sudo chown -R username:username /home/username/.ssh
sudo chmod 0700 /home/username/.ssh
sudo chmod 0600 /home/username/.ssh/authorized_keys