Managing a server that sits in a data center hundreds of miles away requires a secure, reliable connection. You cannot simply plug a keyboard and monitor into a cloud instance. To access the terminal of a remote Linux machine as if you were sitting directly in front of it, you must use the ssh (Secure Shell) command.
The ssh command creates an encrypted tunnel between your local computer and the remote server. Everything sent through this tunnel—passwords, commands, and data—is scrambled, preventing anyone on the network from eavesdropping on your session. In this guide, you will learn how to establish a basic connection and upgrade your security with SSH keys.
Step 1: The Basic Password Connection
Connecting to a remote server requires three pieces of information: the ssh command, the username you want to log in as, and the IP address (or domain name) of the server.
ssh [email protected]
When you run this command for the very first time, your terminal will display a frightening warning: “The authenticity of host ‘192.168.1.50’ can’t be established.”
This is a standard security check. Type yes and press Enter to save the server’s unique digital fingerprint to your computer. You will then be prompted for the password. Note that as you type the password, no characters or asterisks will appear on the screen—this is intentional. Press Enter, and you will be logged into the remote machine.
Step 2: Connecting on a Custom Port
By default, SSH always attempts to connect on Port 22. Because this is universally known, hackers constantly run automated scripts attacking Port 22 on every server they can find. A common security practice is to change the SSH port to a random, high number (like 2244).
If your server administrator has changed the port, a basic ssh command will fail. You must explicitly tell the command which port to use by adding the -p (port) flag.
ssh -p 2244 [email protected]
Step 3: Upgrading to SSH Keys (Passwordless Login)
Relying on passwords is fundamentally insecure. They can be guessed, stolen, or brute-forced. The professional standard for SSH authentication is using Cryptographic Keys.
SSH Keys come in a pair: a Private Key (which stays secretly on your laptop) and a Public Key (which you place on the server). When you try to connect, the server checks if your Private Key mathematically matches its Public Key. If it does, you are logged in instantly without typing a password.
- On your local laptop, open a terminal and generate a key pair by typing:
ssh-keygen. Press Enter through all the default prompts. - You must now copy the Public Key to the remote server. Use this command:
ssh-copy-id [email protected] - It will ask for your password one final time to authorize the transfer.
Once completed, type ssh [email protected] again. You will instantly drop into the remote terminal, completely bypassing the password prompt.
By mastering the ssh command and transitioning to key-based authentication, you ensure that your remote management sessions are both friction-less and mathematically secure against brute-force attacks.