Skip to content

Instantly share code, notes, and snippets.

@rgreenjr
Last active July 19, 2023 08:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rgreenjr/4728c59d923a503087b488e08001df23 to your computer and use it in GitHub Desktop.
Save rgreenjr/4728c59d923a503087b488e08001df23 to your computer and use it in GitHub Desktop.
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment