Create a New Linux User With SSH Access

Published Oct 11, 2019

Generate the key for the user. This should be done on the local machine:

1
ssh-keygen -t rsa -b 4096 -o -a 100

Create a new user on the remote machine. The -m adds a deuser fault user home directory.

1
useradd -m new-user

Switch to the new user:

1
sudo su new-user

Make a .ssh directory for the user:

1
mkdir ~/.ssh

Make an authorized_keys file.:

1
touch ~/.ssh/authorized_keys

Set the right permissions:

1
2
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Add the public key you created to the authorized_keys file.

Resources: