SSH key login can spare you from entering your server account password on every connection. It does not mean SSH stops checking who you are: your computer proves its identity with a private key, and the server checks whether the matching public key is authorized.
The private key stays on your computer. Only the public key belongs on the server.
1. Check for a key before creating one
On Linux or macOS, list your SSH files:
ls -la ~/.ssh On Windows PowerShell:
Get-ChildItem "$HOME\.ssh" -ErrorAction SilentlyContinue A common Ed25519 key pair is named id_ed25519 and id_ed25519.pub. The file without .pub is the private key. If you already have a suitable key, you can use it; don’t overwrite it just to follow this setup. For a new key, these ssh-keygen examples cover key creation and naming across operating systems.
If you need to create one, choose a filename that doesn’t already exist:
ssh-keygen -t ed25519 -C "server-login" Use the equivalent command in PowerShell if that’s where you run SSH. A passphrase is a good choice for an interactive key: it protects the private key on disk. You can use ssh-agent to avoid entering that passphrase each time. The passphrase protects your local key; it is not the remote account password.
2. Install the public key for the right account
You need an existing way to access the server to install the key. If you can log in with a password, ssh-copy-id is a convenient option on systems where it’s available:
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server Replace user@server with the account and hostname you actually use. The command may ask for the remote account password while it installs the public key. The key must be installed for the same user you plan to log in as; authorizing it for deploy does not automatically authorize it for root.
If your SSH server uses another port, specify that when installing the key:
ssh-copy-id -i ~/.ssh/id_ed25519.pub -p 2222 user@server Some macOS installations and the built-in Windows OpenSSH client don’t include ssh-copy-id. Windows-to-Linux setups can append the public key from PowerShell instead:
Get-Content -Raw "$HOME\.ssh\id_ed25519.pub" | ssh user@server 'umask 077; mkdir -p ~/.ssh; chmod 700 ~/.ssh; cat >> ~/.ssh/authorized_keys; chmod 600 ~/.ssh/authorized_keys' That remote command uses a Linux shell and Linux permissions; it is not a recipe for a Windows SSH server. A Windows server uses different authorized-key locations and NTFS permissions. In every case, copy only the .pub file. Never upload or paste the private key.
If no SSH login method works, ssh-copy-id cannot solve that by itself. You’ll need another authorized route, such as an existing administrator session or provider console, to install the public key.
3. Test the key, not just the connection
Try a new login with the private key and verbose output:
ssh -v -o IdentitiesOnly=yes -i ~/.ssh/id_ed25519 user@server IdentitiesOnly=yes tells the client to use the identity you specified rather than trying other available identities. A line saying Offering public key means the client offered a key, but doesn’t prove the server accepted it. Look for output like Authenticated to ... using "publickey" to confirm public-key authentication succeeded.
On Windows PowerShell, use the Windows path for the private key:
ssh -v -o IdentitiesOnly=yes -i "$HOME\.ssh\id_ed25519" user@server A prompt for Enter passphrase for key is asking you to unlock your local private key. A prompt for user@server's password is asking for the remote account password; it usually means key authentication wasn’t used successfully.
4. If SSH still asks for the account password
Check the likely mismatches before generating another key:
- Wrong username: The public key must be authorized for the account in your SSH command.
- Wrong identity: Try the explicit
-icommand above and inspect the verbose output. - Wrong host or port: The key may have been installed on a different server or SSH port. Use the same destination and port for installation and login.
- Server permissions: On a typical Linux setup,
~/.sshshould be mode700andauthorized_keysmode600. The account’s home directory and key files must not be writable by unauthorized users. - Server policy: A managed account or custom SSH configuration may use a different authorization method or key location.
For Permission denied (publickey), this troubleshooting checklist walks through common client and server causes. Start with ssh -v output; it helps identify whether the client offered the expected key and whether the server accepted it.
Passwordless login is not the same as disabling passwords
Once key authentication works, you can use it while password authentication remains enabled as a fallback. Disabling password authentication is a separate server-security decision, not a required setup step. If you choose to do it, first verify a fresh key-based login and keep a working recovery route. Otherwise, a mistake can lock you out.
The basic workflow is simple: protect a private key on your computer, authorize its public half for the intended server account, and confirm the connection authenticated with publickey.
I originally published a more detailed version of this guide on the ShadeTerm blog.
I'm also building ShadeTerm — an SSH client where every server gets its own workspace for terminals, SFTP, code, and databases.