Skip to content

Instantly share code, notes, and snippets.

@rgreenjr
Last active June 4, 2024 09:34
Show Gist options
  • 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