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.
What you need
Section titled “What you need”- 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.
- Connectssh root@IP
- Change password
- Update the system
- Create a user with sudo
- Set up SSH key
- Secure itcontinue with Secure your VPS
Connect to the VPS
Section titled “Connect to the 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.
- Open the Start menu, type
PowerShelland start Windows PowerShell or the Terminal. - Enter (replace the example IP with yours):
ssh root@203.0.113.10- The first time, SSH asks whether you trust the server. Type
yesand confirm with Enter. - Enter the root password. You do not see any characters while typing. That is normal.
- Open the Terminal app (Applications → Utilities).
- Enter:
ssh root@203.0.113.10- Confirm the first prompt with
yesand enter the password. No characters appear while typing.
- Open a terminal.
- Enter:
ssh root@203.0.113.10- Confirm the first prompt with
yesand enter the password.
PuTTY is a free program for Windows from putty.org.
- Start PuTTY.
- Under Host Name (or IP address) enter your IP address, under Port enter
22, and select SSH. - Click Open. The first time, a security prompt about the server’s key appears. Confirm it with Accept.
- At login as: enter
root, then the password.
When you see the prompt, for example root@meinserver:~#, you are logged in.
Change the password
Section titled “Change the password”The password from the customer account is only meant for getting started. Change it right away:
passwdYou 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).
Update packages
Section titled “Update packages”Right after installation, security updates have usually already been released. Which commands you need depends on the distribution.
apt updateapt upgrade -yIf a restart is requested afterwards (for example after a kernel update): reboot. Wait about a minute and reconnect.
dnf upgrade -yAfter a kernel update, restart with reboot and reconnect after a minute.
Do updates regularly in future, for example once a week, or have them installed automatically (Secure your VPS).
Create a user with sudo
Section titled “Create a user with sudo”Do not work as root in everyday use. Create a normal user who may run administrative commands with sudo. Replace anna with your name.
adduser annausermod -aG sudo annaadduser asks for a password and some optional details.
useradd -m annapasswd annausermod -aG wheel annaTest the new user before you continue. Open a second terminal window and log in:
ssh anna@203.0.113.10sudo whoamiIf sudo whoami prints root, everything works.
Set up an SSH key
Section titled “Set up an SSH key”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.
-
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.
-
Copy the public key to the server. On macOS and Linux:
Terminal window ssh-copy-id anna@203.0.113.10On 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.pubOn the server, as user
anna:Terminal window mkdir -p ~/.sshchmod 700 ~/.sshnano ~/.ssh/authorized_keyschmod 600 ~/.ssh/authorized_keysPaste the copied line into the file, save with Ctrl+O, Enter and exit with Ctrl+X.
-
Test logging in without a password. Open a new terminal:
Terminal window ssh anna@203.0.113.10It should now only ask for the key’s passphrase, not for the server password.
Typical problems
Section titled “Typical problems”| 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 |
Frequently asked questions
Section titled “Frequently asked questions”Do I have to change port 22?
Section titled “Do I have to change port 22?”No. A different port helps only a little against automated attacks. SSH keys and Fail2ban are more effective.
I locked myself out. What now?
Section titled “I locked myself out. What now?”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.
Is there SSH for my game server too?
Section titled “Is there SSH for my game server too?”No. For game servers there is SFTP instead of SSH, see Files, editor and SFTP.