Article

Table of Contents
Theme:
Was this article helpful?

1  out of  1 found this helpful

Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $300 by adding new articles!

Use an SSH Key with Non-root Users

Last Updated: Wed, Aug 5, 2020
Linux Guides Popular Security

Vultr provides a feature that allows you to pre-install SSH keys upon creating a new instance. This allows you to access the server's root user, however, the key will not work out of the box with newly created non-root users. This Quickstart Guide describes how to use your pre-installed SSH key with newly created users.

Requirements

Deploy the SSH key to the User

In this guide, the non-root user is named example_user.

  1. SSH to the server as root.
  2. Create the .ssh directory for the non-root user.

    # mkdir /home/example_user/.ssh
    
  3. Open your SSH key in the Customer Portal. Copy the key to the clipboard.

    You can use any OpenSSH format key, it's not required to share the same key you deployed to the root user. In fact, sharing keys is a poor security practice. This example is for illustration.

    SSH key

  4. Edit /home/example_user/.ssh/authorized_keys.

    # nano /home/example_user/.ssh/authorized_keys
    
  5. Paste the key at the bottom of the .ssh/authorized_keys file.

  6. Save and exit.
  7. Verify the ownership and permissions for the SSH keys are correct.

    # chown -R example_user:example_user /home/example_user/.ssh
    # chmod 600 /home/example_user/.ssh/authorized_keys
    

You non-root user can now use the SSH key.

More Information

For more information about managing SSH keys, see our other guides:

Want to contribute?

You could earn up to $300 by adding new articles