Guides

Why SSH still asks for a password when your key is set up — 3 causes

Illustration: a key lies in front of a door with a keypad, next to a box with its lid ajar

You made an SSH key, put it on the server, followed the guide. You connect — and SSH asks for a password again. What was all that for?

Here's the first thing to do: read the question carefully. SSH asks for a password with two different phrases, and they're two different problems:

Enter passphrase for key '/home/you/.ssh/id_ed25519':
[email protected]'s password:

The first is the password of your key. The second is the password of the user on the server. Half of all "SSH won't take my key" cases are actually the first line. And it's fixed in a completely different way.

First: turn on verbose mode

Before fixing blind, ask SSH what it's doing:

ssh -v [email protected]

In the output, find two lines:

  • Offering public key: /home/you/.ssh/id_ed25519 — which key the client offered the server.
  • Authentications that can continue: publickey,password — the server answered "didn't work, try something else."

If the second line comes right after the key offer, the server rejected the key. If there's no Offering public key line at all, the client never even showed a key. That's half the diagnosis.

Cause 1. It's the key's password, not the server's

Symptom: the question starts with Enter passphrase for key.

That means everything works. The server accepted the key. The key is just protected by a passphrase, and SSH asks for it to unlock the private key on your computer.

How to fix. Don't remove the passphrase — it protects the key if your laptop is stolen. Instead, hand the key to the agent: it remembers the unlocked key until the session ends.

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

You're asked once, then silence. To skip doing this by hand, add to ~/.ssh/config:

Host *
  AddKeysToAgent yes

On macOS, add UseKeychain yes there too — then the key's passphrase is kept in the system keychain and isn't asked again after a reboot.

Cause 2. The server doesn't see your key

Symptom: the question is user@host's password:, and in ssh -v the key was offered but rejected.

The most common variants:

  • Wrong user. The key belongs to deploy, but you log in as root. Each user on the server has their own ~/.ssh/authorized_keys file.
  • Key copied to the wrong place. The public key must go exactly into authorized_keys, as one line, with no line breaks. A long RSA key is easy to truncate when copying — one more reason for a short Ed25519 key.

How to fix. Don't copy by hand — there's a command that does it right:

ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]

It asks for the server password one last time and appends the key where it belongs.

Cause 3. Wrong permissions on the server

Symptom: the key is definitely there, the user is right, and the server still asks for a password. This is the sneakiest cause — because you see no errors at all.

By default the SSH server strictly checks permissions on your files. If your home folder, ~/.ssh or authorized_keys is writable by anyone but you, the server decides the file could have been swapped by someone else. And it silently ignores the key. No message to you — only an entry in the server log.

How to check. Log in to the server with the password and look at the log:

sudo journalctl -u ssh -n 30

Look for the line Authentication refused: bad ownership or modes. On some systems the log lives in /var/log/auth.log.

How to fix:

chmod go-w ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Permissions often break unnoticed: a file was created with a loose mask or copied from an archive. Where new files get their permissions from is covered in what umask is.

How to tell which cause you have

  • The question is Enter passphrase for key → cause 1, you need the agent.
  • No Offering public key in ssh -v → the client didn't find the key. Point to it in the config with IdentityFile.
  • The key was offered and rejected → check the user and authorized_keys (cause 2), then permissions (cause 3).

FAQ

Can I turn off password login completely?

Yes, and it's good practice for a server: set PasswordAuthentication no in /etc/ssh/sshd_config. But first make sure key login works — or you'll lock the door with yourself outside.

Why does SSH say "Too many authentication failures"?

The client tried all your keys from the agent, and the server hit its attempt limit before reaching the right one. Set the right key in the config and add IdentitiesOnly yes.

Does this apply to GitHub?

Partly. Permissions on GitHub's servers aren't your concern, but the passphrase and agent work the same way. Test your key with ssh -T [email protected].

Become an AI architect — don’t just read about AI

The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.

About the Academy
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →