Skip to content

Instantly share code, notes, and snippets.

@jrjhealey
Last active February 10, 2020 12:56
Show Gist options
  • Save jrjhealey/da10b4b3fa57aed3acdf5585a18ba806 to your computer and use it in GitHub Desktop.
Save jrjhealey/da10b4b3fa57aed3acdf5585a18ba806 to your computer and use it in GitHub Desktop.
Adding Server Users (reminder for myself)
# Step 1
# Add the user with
sudo adduser username
# Ensure a temporary password is given to the account else it remains locked
# other options can be left blank
# Add the username to the AllowedUsers field in /etc/ssh/sshd_config (on the server)
# Next step is often easier to do as the new user to avoid messing up file ownership
sudo -i -u newuser
# Copy the users RSA public key in to the authorized_users file in their home directory.
mkdir /home/newuser/.ssh
chmod -R newuser:newuser 700 /home/newuser/.ssh # if files are created as the new user, the group ownerships (user:user) can be omitted
touch /home/newsuer/.ssh/authorized_keys
chmod -R newuser:newuser 600 /home/newuser/.ssh/authorized_keys
# Copy and paste the public key in to the empty authorised keys.
# Restard the SSH daemon to confirm the changes:
sudo service ssh restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment