Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleUbuntu 20.04 Focal

For each user, do the following:

First you create the user account using the adduser command. Note that this command will prompt you for some additional details.

Code Block
sudo adduser <username> --disabled-password

You then want to set up the user’s SSH authorized keys file and add their SSH public key to it using an editor of your choice. Please note that key formatting is very important, several examples of acceptable key types and formats are provided below.

Code Block
languagenone
sudo mkdir /home/<username>/.ssh
sudo touch /home/<username>/.ssh/authorized_keys

sudo vim /home/<username>/.ssh/authorized_keys

sudo chown -R <username>:<username> /home/<fed-id>/.ssh
sudo chmod -R 0700 /home/<username>/.ssh

Your user should now be able to log in to your machine with their SSH public key using the following command.

Code Block
ssh <username>@<ip address>

If you also want the newly added user to have sudo permissions then you need to edit the /etc/sudoers.d/cloud file using the following command.

Code Block
sudo visudo /etc/sudoers.d/cloud

Adding the following line to the bottom. Note that because we do not set a password for the user, the NOPASSWD option is necessary.

Code Block
<username> ALL=(ALL) NOPASSWD: ALL

Example Public Keys

The following keys are all examples used to demonstrate acceptable formatting of public keys in authorized keys files.

Code Block
# RSA-2048
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDdIsfXr82WFXNfw+RfECqitp/5wPeR670TO8gj/F7ypRPi80wLRKBF85LVN9T/E0b0+Ur6E1sMRWI9xAnxW2O1uSZ4f1TqlzbL4jqmbQuGRNIKroyOtHwmHiLca5fbwLRyXLXXyjSOp//8QMzM8SaslavAv8sGPvrGMtceytGIpVi90OrArFJYfDbUOs7mqfNATYBcMl2Ql/cnnHPrHiRU9VCMc05cjymoy9DHZN5Enfnew+Q/NBODpQd8yvQV2EJj3mduKJc3MGj/xR8ODux0hI3iPUM9DRHxEYl3+RzQV3xXHRycv3tJzvDIgtCYT3cp/scXKiecmMh6Kprq+JH rsa-key-20240816

# ECDSA (nistp384)
ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBE60HgYZDYWngeNi88Ymy0TVhYQsTJ7SvKT6XFeun5tIfUJ1jssy7yZVygZguK9ci9ojdP5s70XDjoOdM0C0wdqyC3KX/dRz6iwrwadT4IqZZOsNJrddKJBxsqZ3TNTqKA== ecdsa-key-20240816

# EdDSA (Ed25519)
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJx6CptzpgLxJwvHXa1OAh2CzyaDHw0esi7ZuWKK9quy eddsa-key-20240816