Tropic Host

How to connect to a Linux server over SSH: commands for Linux, macOS, and Windows

5 min read
Tropic
How to connect to a Linux server over SSH: commands for Linux, macOS, and Windows

How to connect to a Linux server over SSH

An SSH connection is useful when you need to access a Linux server in a terminal, install packages, inspect logs, restart a service, or upload a project. For a first connection, you do not need a long theory lesson: in most cases, one command and the correct access details are enough.

Below you will first find the quickest way to connect, followed by short notes for Windows, Linux, and macOS, common errors, and basic security practices.

How to connect to a Linux server over SSH quickly

If you already have the server IP address, username, and a password or key, little preparation is required. In most cases, the first login comes down to one command:

ssh username@server_ip

If the SSH server listens on a non-standard port, add it with -p:

ssh -p 2222 username@server_ip

If the server is configured for key-based login, specify the path to the private key:

ssh -i ~/.ssh/id_ed25519 username@server_ip

That is enough to access the server quickly and start working. It is still worth understanding which details are required, how connections differ between operating systems, and how to make access safer.

What you need to connect

SSH, or Secure Shell, is a secure way to open a server's command line remotely. A first connection usually requires:

  • the server IP address or domain;
  • a username, such as root, ubuntu, admin, or another account;
  • a password or private SSH key;
  • the SSH port, if a non-standard 22 is used;
  • SSH access enabled on the server itself.

After a successful login, you will reach the remote Linux server's terminal and can run commands as if you were working locally.

If the server uses keys

When you log in with a key, the server checks whether your private key matches the public key already added to the server. A password may not be used at all in this scenario. Key-based access is generally more reliable and convenient for regular work.

The usual sequence is:

  1. Create a key on your computer.
  2. Add the public key to the server.
  3. Connect through ssh without entering a password each time.

On Linux and macOS, a key is often generated with:

ssh-keygen -t ed25519

How to connect from Linux and macOS

SSH is usually already installed on Linux and macOS. Open a terminal and run:

ssh username@server_ip

If another port is required:

ssh -p 2222 username@server_ip

For a key-based connection, use:

ssh -i ~/.ssh/id_ed25519 username@server_ip

After the first login, it is useful to confirm that you reached the intended server immediately:

hostname
whoami

This is a simple but valuable habit, especially when you manage several servers and environments.

How to connect from Windows

Windows offers two practical options: the built-in OpenSSH in PowerShell or Windows Terminal, and a separate client such as PuTTY. For most tasks, the built-in option is the simplest place to start.

Open PowerShell and run:

ssh username@server_ip

For a non-standard port:

ssh -p 2222 username@server_ip

If you use a key, specify its path:

ssh -i $env:USERPROFILE\.ssh\id_ed25519 username@server_ip

PuTTY follows the same logic: enter the address, port, and username, and for key-based authentication load a .ppk key in the client settings.

What to check in Windows if SSH does not start

Sometimes the built-in SSH client is simply not installed. In Windows settings, enable the OpenSSH Client component, or use PuTTY as a temporary solution.

Common connection errors

The problem is often not the command itself but one of its parameters.

Connection refused

This usually means that the SSH service is not running on the server or that the port is closed. Check that sshd is running and that the required port is open in the firewall and in the server control panel.

Permission denied

The username, password, or key is most often incorrect. Check:

  • the login name;
  • the correct key path;
  • whether the public key is present on the server;
  • whether the key matches the one expected by the server.

Host key verification failed

This message is related to known_hosts, the list of servers already known to SSH. It can appear after reinstalling the operating system, changing an IP address, or recreating a server. If you are sure that you are connecting to the intended machine, remove the old entry:

ssh-keygen -R server_ip

Then connect again and confirm the server's new key.

Could not resolve hostname

This means that the hostname cannot be found in DNS or that the address contains a typo. As a check, try connecting by IP address.

How to connect more securely

SSH itself is protected, but a few basic settings greatly reduce the risk of mistakes and unnecessary log noise.

Use SSH keys instead of a password

Key-based authentication is usually more reliable for regular work and more convenient. If the server is already configured for keys, use them from the start.

Disable login as root

Direct root login is not needed for everyday work. It is safer to connect as a regular user and elevate privileges with sudo only when necessary.

Change the standard port as an additional measure

Port 22 can be changed to another value, such as 2222. This does not make a server invisible to attacks, but it reduces the number of random scans and bots that look only for the standard port.

Check known_hosts

When SSH warns that the server key has changed, do not ignore the message. The reason may be harmless, but it can also indicate impersonation. If the server was genuinely reinstalled or replaced, first confirm this in the control panel or with an administrator, then update the entry in known_hosts.

How this relates to choosing a server

When you rent a VPS or dedicated server, SSH becomes your main working channel. Through it, you install packages, update the system, deploy Docker, inspect logs, and check service status. If access works predictably, you spend time on your work instead of investigating strange login problems.

That is why, when choosing a hosting provider, it is useful to look beyond CPU, RAM, and disk space. Consider how quickly you can obtain clear SSH access, see the server parameters, and start administering it. For these tasks, tropic.host is a practical option for quickly starting with a VPS without unnecessary preparation.

Short conclusion

Connecting to a Linux server over SSH is usually straightforward: you need an address, a user, and either a password or a key. On Linux and macOS, a terminal is enough; on Windows, you can use the built-in OpenSSH or PuTTY. If the connection fails, first check the port, login, key, and known_hosts, then inspect the server settings. For regular work, switch to SSH keys, disable login as root, and use a non-standard port as an additional measure.

FAQ

What SSH command should be used for the first connection?

Usually, ssh username@server_ip is enough. If SSH runs on another port, add -p.

Can I connect to a Linux server over SSH from Windows?

Yes. The simplest option is PowerShell or Windows Terminal with the built-in ssh command. PuTTY is an alternative.

What should I do if SSH asks me to confirm a new server key?

If the server was genuinely reinstalled or its IP address changed, this is normal. If you are not sure why it happened, first verify that you are connecting to the intended machine.

Why is an SSH key better than a password?

A key is convenient for regular work and is usually more reliable than a password. It reduces the risk of credential guessing and makes it possible to log in without entering a password repeatedly.

Is it mandatory to change the SSH port?

No, it is not mandatory. However, changing the port is useful as an additional layer against broad automated scans.