Connect to Your Server via SSH

Learn how to securely connect to your server using SSH from your local machine, on any operating system.

3 min
LinuxSSHServerRemote Access

Connecting to your server via SSH is the first step to managing your server.

Connect to Your Server via SSH

On your local machine (Windows, macOS, or Linux), open a terminal/command prompt/PowerShell and run:

bash logo
ssh root@your-server-ip

Replace root with the username you created. If you never created one, it is likely root. You also need to replace your-server-ip with the actual IP address of your server.

Depending on your server setup, you might be prompted to enter a password, or it will use your SSH key if you set that up during provisioning.

If this is the first time ever connecting, you will see a warning about the authenticity of the host:

bash logo
The authenticity of the host 'your-server-ip (your-server-ip)' can't be established.
ED25519 key fingerprint is SHA256:HIDYV97UfPJp8H45roWU+0UNVCjbzWZfhTvbpS2saPQ.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Type yes and press enter. This will add this fingerprint to your local known_hosts file, so you won’t see this warning again. The terminal will show a message like this:

bash logo
Warning: Permanently added 'your-server-ip' (ED25519) to the list of known hosts.

Once you are connected, you will be greeted with a welcome message from your server, and you can start running commands and managing your server.

To exit the SSH session, type exit and press enter.

Connecting with a non-standard SSH port (22 is the default)

By default, ssh connects to port 22. In some cases, your server’s ssh port is different, so to connect, you can use this command.

bash logo
ssh -p your-ssh-port your-username@your-server-ip

Replace your-ssh-port with your server’s SSH Port.

Connecting with a specific SSH key

If the ssh key needed to connect to your server is not your local machine’s default ssh key, you need to supply it.

bash logo
ssh -i /path/to/your/private/key your-username@your-server-ip

Replace /path/to/your/private/key with the path to your ssh private key file.

Common Issues

Permission denied (publickey)

If you get a Permission denied (publickey) error, it could mean either of the following.

  • The private key used is not configured on the server.
  • You might be using a key configured for that server, but for a different user.

Permission denied, please try again

If you get the Permission denied, please try again error, most likely you entered the wrong password. Check your password and the user you are trying to connect as, then try again.

REMOTE HOST IDENTIFICATION HAS CHANGED

If you get REMOTE HOST IDENTIFICATION HAS CHANGED! error, it could mean one of two things.

A man-in-the-middle attack is happening

An Attacker is trying to intercept your connection. If you have not reset/reinstalled your server, then this is a possibility. Don’t ignore the error; investigate further.

You reset/reinstalled your server and kept the same IP

  • You have reset/reinstalled your old server, and it kept the same IP. In that case, go to your known_hosts file, usually located in ~/.ssh/known_hosts

Open the file in your favorite text-editor

Windows CMD
notepad
notepad %USERPROFILE%.sshknown_hosts
vs code
code %USERPROFILE%.sshknown_hosts
cursor
cursor %USERPROFILE%.sshknown_hosts
zed
zed %USERPROFILE%.sshknown_hosts
neovim
nvim %USERPROFILE%.sshknown_hosts
Windows PowerShell
notepad
notepad $HOME/.ssh/known_hosts
vs code
code $HOME/.ssh/known_hosts
cursor
cursor $HOME/.ssh/known_hosts
zed
zed $HOME/.ssh/known_hosts
neovim
nvim $HOME/.ssh/known_hosts
Linux/macOS
nano
nano ~/.ssh/known_hosts
vim
vim ~/.ssh/known_hosts
vs code
code ~/.ssh/known_hosts
cursor
cursor ~/.ssh/known_hosts
zed
zed ~/.ssh/known_hosts
neovim
nvim ~/.ssh/known_hosts

Look for the line that contains your server’s IP and delete it. Save and try to connect again.