Skip to content

05VPS & dedicated servers

Connect to a VPS via SSH – first steps on Windows, macOS, Linux

How to log in to your Nexthosting VPS via SSH, change the password, update the system, create a user and set up SSH keys.

In short

You connect with ssh root@YOUR-IP in a terminal or with PuTTY and log in with the root password from the customer account. After that you change the password, install updates, create your own user and add an SSH key. You add the key only after the first login; there is no field for it when ordering.

  • the IP address of your VPS and the root password, both in the customer account on the product page in the Übersicht (overview) tab
  • a terminal (see below) or PuTTY
  • about 15 minutes

You get there via Dienste (services) → Deine Produkte (your products) → Ansehen (view) next to your VPS. The root password is hidden; a click on the eye icon shows it. New VPS run Ubuntu 22.04. If something goes wrong, a ticket helps. How a VPS is set up and what you are responsible for is explained under VPS overview.

The path in this chapter
  1. Connectssh root@IP
  2. Change password
  3. Update the system
  4. Create a user with sudo
  5. Set up SSH key
  6. Secure itcontinue with Secure your VPS

SSH (Secure Shell) is an encrypted access to the command line of your server. Everything you type runs on the VPS, not on your computer.

Windows 10 and 11 come with an SSH client.

  1. Open the Start menu, type PowerShell and start Windows PowerShell or the Terminal.
  2. Enter (replace the example IP with yours):
Terminal window
ssh root@203.0.113.10
  1. The first time, SSH asks whether you trust the server. Type yes and confirm with Enter.
  2. Enter the root password. You do not see any characters while typing. That is normal.

When you see the prompt, for example root@meinserver:~#, you are logged in.

The password from the customer account is only meant for getting started. Change it right away:

Terminal window
passwd

You enter a new password twice. Use a long, random password from a password manager. If you forget it, set a new one in the Passwort ändern (change password) tab in the customer account. After hardening you will not need it for logging in at all (see Secure your VPS).

Right after installation, security updates have usually already been released. Which commands you need depends on the distribution.

Terminal window
apt update
apt upgrade -y

If a restart is requested afterwards (for example after a kernel update): reboot. Wait about a minute and reconnect.

Do updates regularly in future, for example once a week, or have them installed automatically (Secure your VPS).

Do not work as root in everyday use. Create a normal user who may run administrative commands with sudo. Replace anna with your name.

Terminal window
adduser anna
usermod -aG sudo anna

adduser asks for a password and some optional details.

Test the new user before you continue. Open a second terminal window and log in:

Terminal window
ssh anna@203.0.113.10
sudo whoami

If sudo whoami prints root, everything works.

An SSH key consists of two files: a private key that stays on your computer, and a public key that you put on the server. The server lets you in if your computer holds the private key. That is more secure than a password because a key cannot be guessed.

When ordering a VPS you cannot specify a key. So you put it on the server yourself after the first login, with ssh-copy-id or by hand in the user’s authorized_keys file.

  1. Generate a key on your own computer (not on the server). In PowerShell, in the terminal or on Linux:

    Terminal window
    ssh-keygen -t ed25519 -C "mein-vps"

    Confirm the storage location with Enter. Set a passphrase so that the key is protected even if it is stolen.

  2. Copy the public key to the server. On macOS and Linux:

    Terminal window
    ssh-copy-id anna@203.0.113.10

    On Windows there is no ssh-copy-id. Instead, display the key, copy the line and paste it on the server:

    Terminal window
    type $env:USERPROFILE\.ssh\id_ed25519.pub

    On the server, as user anna:

    Terminal window
    mkdir -p ~/.ssh
    chmod 700 ~/.ssh
    nano ~/.ssh/authorized_keys
    chmod 600 ~/.ssh/authorized_keys

    Paste the copied line into the file, save with Ctrl+O, Enter and exit with Ctrl+X.

  3. Test logging in without a password. Open a new terminal:

    Terminal window
    ssh anna@203.0.113.10

    It should now only ask for the key’s passphrase, not for the server password.

Message Cause Solution
Connection timed out Server unreachable or a firewall blocks port 22 Check the IP, check whether the VPS is running (customer account, Übersicht tab), check the firewall in the Netzwerk (network) tab
Connection refused The SSH service is not running or listens on a different port Check via the VNC tab in the customer account or write a ticket
Permission denied (publickey) The server only accepts keys and yours is not stored Add your public key
Permission denied, please try again Wrong password Enter the password again, mind upper and lower case
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED The server was reinstalled and has a new fingerprint Delete the old entry with ssh-keygen -R 203.0.113.10

No. A different port helps only a little against automated attacks. SSH keys and Fail2ban are more effective.

Open the VNC tab of your VPS in the customer account. It is a console in the browser that works without SSH. Log in there with your user and password and correct the SSH settings. With Passwort ändern you set a new root password. As a last resort, reinstall the VPS in the Neuinstallieren tab (all data is lost) or write a ticket.

No. For game servers there is SFTP instead of SSH, see Files, editor and SFTP.