Skip to content

SSH keys and root access ​

This guide covers how SSH keys are safer than passwords, how to create and add a key, and how root and sudo access work. You will also learn some basic Linux navigation.

Before you begin ​

  • SSH access to your VPS. See Access details and SSH.
  • A computer where you can create a key pair.
  • Confirmation that your plan gives you root access. Some plans may limit it.

Keep private keys private

A private key is a secret. Never share it, email it, or store it in a public place. Only the public key goes on the server.

Steps ​

Create a key pair (on your own computer)

  1. On your own computer, choose an unused key filename. Never overwrite an existing private key when prompted:

    bash
    ssh-keygen -t ed25519 -C "your-label"
  2. Set a passphrase when asked. It protects the key if someone gets the file.

Add the public key to the server ​

  1. Copy the contents of the public key file, which ends in .pub.
  2. Add it to the server's authorised keys for your user, using the method your VPS documentation shows.
  3. Test the key in a new terminal before you close your current session.

Root and sudo ​

  1. Use your normal user for daily work, and use sudo only for the commands that need it.
  2. Avoid logging in directly as root for everyday tasks.
  3. Check what you are about to run before you add sudo to it.

Basic Linux navigation ​

  • pwd shows where you are. ls -la lists files. cd folder moves into a folder.
  • cat file prints a file. nano file opens a simple editor.
  • df -h shows disk space. free -h shows memory.

Expected result ​

You can sign in with your key, and sudo works for the commands you need.

If something goes wrong ​

  • The key is refused. Check that you copied the public key, not the private key, and that the file permissions are correct.
  • Locked out after a change. Keep your current session open while you test a new key. If you are locked out, contact support.
  • Sudo asks for a password you do not know. Your user may not have sudo access. Check your plan or ask support.

Last reviewed ​

2026-10-28