Connect to a Linux Server with SSH: A Beginner Guide
Before you begin
- Applies to:A private Linux lab with a working OpenSSH server and a regular account that can sign in with a password.
- Where to start:Open Bash on the client. Use the server console when checking the server’s identity or recovering access.
- What you need:Have the server address, lab username, console access, and the OpenSSH client tools ssh, ssh-keygen, and ssh-copy-id.
Guide tools
SSH opens an encrypted terminal session on another machine. Your commands run on that remote machine, so checking which machine you are using matters.
You will connect to an existing Linux lab server, verify its identity, and set up a login key. You need two machines or a client plus a Linux virtual machine. This guide begins with a working SSH server and password-enabled lab account; it does not configure a new internet-facing server.
Trusted lab address → Compare fingerprint → Keep private key safe → Confirm remote account.
Check the Client Tools
ClientOn the client: ssh -V prints the OpenSSH version. command -v prints where a tool is installed. You need all three tools before continuing. Linux distributions often provide ssh-copy-id in their OpenSSH client package; use the package manager guide if one is missing.
ssh -Vcommand -v ssh-keygencommand -v ssh-copy-id❯ What to expect
An OpenSSH version and paths for both tools.If a path is missing, install the appropriate client package first.Get the Server Fingerprint Through Its Console
Server ConsoleOn the server console: use a trusted local console or hypervisor console to read the server’s Ed25519 public host-key fingerprint. -l lists a fingerprint and -f selects the public-key file. Keep this value for the next step. This key identifies the server; it is different from your personal login key.
sudo ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub❯ What to expect
A line beginning with 256 SHA256: followed by a fingerprint.It ends with a host comment and (ED25519).Your actual fingerprint must be obtained from your own server.Connect and Verify the Server Identity
ClientOn the client: the option -o HostKeyAlgorithms=ssh-ed25519 selects the same host-key type you checked. At the first-connection prompt, compare the complete SHA256 fingerprint with the trusted console result. Type yes only if they match, then enter the server account password. The server may already be known; in that case SSH does not repeat the prompt.
❯ What to expect
First connection: an authenticity question with an ED25519 fingerprint.After verification and authentication: a shell prompt on your server.Confirm Which Machine You Are Using, Then Disconnect
Remote SessionInside the SSH session: hostname displays the server’s name and whoami displays your remote username. exit closes the remote shell and returns you to the client. Check that the remote identity is the one you intended before running administration commands.
hostnamewhoamiexit❯ What to expect
Your server hostname, then your remote account name.After exit: Connection ... closed, and your client prompt returns.Create Your Personal Login Key on the Client
ClientBack on the client: create the .ssh directory if necessary. chmod 700 makes that directory accessible only to its owner. ssh-keygen -t ed25519 creates an Ed25519 key pair; -f chooses a dedicated filename and -C adds an identifying comment. Enter a strong, unique passphrase when prompted; it protects the private key on disk. No characters appear while typing it.
mkdir -p "$HOME/.ssh"chmod 700 "$HOME/.ssh"ssh-keygen -t ed25519 -f "$HOME/.ssh/configcorner_lab_ed25519" -C "ConfigCorner lab"❯ What to expect
Two passphrase prompts, then paths for:~/.ssh/configcorner_lab_ed25519 (private key)~/.ssh/configcorner_lab_ed25519.pub (public key)Install Only the Public Key on the Server
ClientOn the client: ssh-copy-id adds your public key to the remote account’s authorized keys, preserving existing keys. -i selects your .pub file. It may ask for the server account password. This deliberately changes that account’s SSH authorization; use only your approved lab account.
ssh-copy-id -i "$HOME/.ssh/configcorner_lab_ed25519.pub" -o HostKeyAlgorithms=ssh-ed25519 [email protected]❯ What to expect
Normally: Number of key(s) added: 1.If it reports the key already exists, do not repeatedly append it.Test That Key Authentication Works
ClientOn the client: -i selects your private key. IdentitiesOnly=yes selects the configured identity rather than trying every agent key. The last three options allow public-key authentication and disable password and keyboard-interactive fallbacks for this connection. You may still be asked for the local key passphrase; that is expected.
ssh -i "$HOME/.ssh/configcorner_lab_ed25519" -o IdentitiesOnly=yes -o PreferredAuthentications=publickey -o PasswordAuthentication=no -o KbdInteractiveAuthentication=no [email protected]❯ What to expect
A key-passphrase prompt, if the key is not already unlocked, then a remote shell.A server-account password prompt should not be used for this test.Verify the Remote Account and End the Session
Remote SessionInside the new SSH session: verify the destination again, then disconnect. You have completed a key-authenticated login while retaining your original recovery access.
hostnamewhoamiexit❯ What to expect
The correct server name and account, then your client prompt.If the connection does not work
| Message | What to check next |
|---|---|
| Connection timed out | Confirm the address, route/VPN, and firewall rules with the lab owner. |
| Connection refused | Confirm SSH is running and listening on the expected port through the server console. |
| Permission denied (publickey) | Check the account, selected key, and public-key installation. An administrator can inspect SSH logs, ownership, permissions, and security labels. |
| Incorrect key passphrase | Use the passphrase created on the client, rather than the server password. |
| No matching host key type | Check server policy and supported algorithms through its console. Do not enable obsolete algorithms to force a connection. |
References and next steps
Your feedback keeps these production procedures accurate and battle-tested.