What "Permission denied (publickey)" actually means
When you see user@host: Permission denied (publickey)., the network part of SSH worked. Your computer reached the server, the encrypted connection was set up and the server proved its identity. What failed is the next step: user authentication. The server told your client which login methods it accepts (the word in brackets), your client tried every key it had, and the server accepted none of them.
That narrows the problem to four places:
- The client did not offer the right private key, or could not read it.
- The username is wrong, so the server checks the wrong account's keys.
- The server cannot find or will not trust the matching public key in
authorized_keys, often because of file permissions. - The server's settings refuse this user or this key type, for example
PermitRootLogin noor an old RSA key.
This is a different problem from "Connection refused" or "Connection timed out", which mean you never reached the SSH service at all. If you see one of those instead, use our SSH connection refused guide.
Step 1: run ssh -v and read the authentication lines
Guessing wastes time. The -v flag makes the client print what it is doing, and the ssh manual describes it as the tool for debugging connection, authentication and configuration problems. Run the same command that fails, with -v added:
ssh -v deploy@203.0.113.10
Ignore the first screen of output and look for these lines near the end:
debug1: Authentications that can continue: publickey
debug1: Offering public key: /home/you/.ssh/id_ed25519 ED25519 SHA256:...
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
deploy@203.0.113.10: Permission denied (publickey).
What they tell you:
- No "Offering public key" line at all: your client has no key to offer. It is not in the default location, the agent is empty, or the file was ignored because of its permissions.
- "Offering public key" for the wrong file: the client is sending a different key from the one installed on the server. Point it at the right one with
-i. - "Offering public key" for the right file, then refused: the client side is fine. The server does not accept that key for that user, so the fix is on the server.
- "Server accepts key" but still denied: the key matched, but the client could not use the private key, usually a wrong passphrase or an unreadable file.
Add more letters (-vv, -vvv) for more detail if needed. Remove your hostnames and IP addresses before you paste the output anywhere public.
Quick diagnosis table
| What you see | Most likely cause | First thing to try |
|---|---|---|
No "Offering public key" line in ssh -v | Key not found, not loaded or ignored | ls -l ~/.ssh, then ssh -i ~/.ssh/id_ed25519 ... |
WARNING: UNPROTECTED PRIVATE KEY FILE! | Private key readable by other users, so ssh ignores it | chmod 600 ~/.ssh/id_ed25519 |
| Key offered, then refused | Public key missing from the server's authorized_keys, wrong user, or bad permissions on the server | Check the username, then the server's auth log |
Too many authentication failures | The agent offered many keys and hit the server's attempt limit | -o IdentitiesOnly=yes -i ~/.ssh/key |
no mutual signature algorithm in -v output | Old ssh-rsa (SHA-1) signatures, disabled by default since OpenSSH 8.8 | Use an Ed25519 key |
Works as root, fails as deploy (or the reverse) | Key installed in the other account's authorized_keys, or PermitRootLogin / AllowUsers blocks the user | sudo sshd -T | grep -i -E 'permitrootlogin|allowusers' |
git@github.com: Permission denied (publickey) | Key not added to your GitHub account, wrong user in the remote URL, or sudo git | ssh -vT git@github.com |
Permission denied (publickey,password) | Password login is also allowed; the key failed and the password was wrong or skipped | Fix the key; do not rely on the password |
Fixes on your computer (the client)
Check the key exists and use it explicitly
On Ubuntu, macOS or Git Bash on Windows, list your keys:
ls -l ~/.ssh
You should see a pair such as id_ed25519 (private) and id_ed25519.pub (public). By default ssh tries ~/.ssh/id_rsa, id_ecdsa, id_ecdsa_sk, id_ed25519 and a few others. If your key has another name, such as mumbai-vps or a .pem file a panel gave you, ssh will not find it on its own. Name it:
ssh -i ~/.ssh/mumbai-vps -o IdentitiesOnly=yes deploy@203.0.113.10
IdentitiesOnly=yes tells ssh to use only the keys you configured, even if the agent holds others. If you have no key at all, create one with ssh-keygen -t ed25519 and install the public half on the server, as our SSH keys guide shows.
Fix permissions on the private key
The ssh manual says private key files should be readable by you and not accessible by others, and that ssh will simply ignore a private key file if it is accessible by others. You will see a warning such as Permissions 0644 for '/home/you/.ssh/id_ed25519' are too open. Fix it with:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519
chmod 644 ~/.ssh/id_ed25519.pub
On Windows, the same rule applies to keys in C:\Users\you\.ssh. If you copied a key from another drive or a shared folder, open the file's Properties, then Security, and remove access for every account except your own.
Save the host in ~/.ssh/config
Once a command works, stop retyping it. Add an entry to ~/.ssh/config:
Host mumbai-vps
HostName 203.0.113.10
User deploy
IdentityFile ~/.ssh/mumbai-vps
IdentitiesOnly yes
Now ssh mumbai-vps uses the right user and key every time, and so do scp, rsync and Git. The manual says this file must not be writable by others, so keep it at chmod 600.
"Too many authentication failures"
If ssh-add -l lists many keys, your client offers each one in turn. The server counts each as a failed attempt, and MaxAuthTries defaults to 6, so it may disconnect you before it reaches the right key. The IdentitiesOnly setting above fixes this.
Old RSA keys and "no mutual signature algorithm"
OpenSSH 8.8, released in September 2021, disabled RSA signatures that use the SHA-1 hash (the ssh-rsa algorithm) by default, because SHA-1 is broken. Ubuntu 22.04 ships OpenSSH 8.9 and Ubuntu 24.04 ships 9.6, so both have this default. For most users nothing changes, because RSA keys automatically use SHA-256 or SHA-512 signatures where the other side supports them. The problem appears when the other end is very old, such as an old appliance, router or a long-unpatched server. In the -v output you may see no mutual signature algorithm just before the key is skipped.
The lasting fix is a new key type: create an Ed25519 key and install it. The release notes show a stopgap for a single old host, which you should remove once the old side is upgraded:
Host old-host
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
Fixes on the server
If the client offers the right key and the server still refuses it, you need a shell on the server to look. Use another working login, a password session if one is still allowed, or your provider's out-of-band console. Do not close an open session while you change SSH settings.
Read the server log first
The client is told only "denied". The server log says why. On Ubuntu 24.04 and 22.04 the service is called ssh:
sudo journalctl -u ssh -n 50 --no-pager
sudo tail -n 50 /var/log/auth.log
Try the login again from your computer and watch for new lines. Messages about "bad ownership or modes" point at permissions; a line saying the user is not allowed points at AllowUsers or PermitRootLogin; a line about a key type not being accepted points at PubkeyAcceptedAlgorithms.
Check the public key is really in authorized_keys
By default sshd reads .ssh/authorized_keys (and .ssh/authorized_keys2) in the home directory of the user you log in as. A key in /root/.ssh/authorized_keys does nothing for deploy, and the reverse. Compare the key on your computer with the file on the server:
# on your computer
cat ~/.ssh/id_ed25519.pub
# on the server, as the target user
cat ~/.ssh/authorized_keys
Each key must be one single line: type, long base64 string, optional comment. Common faults are a line broken in two by copy and paste, a private key pasted by mistake (it starts with -----BEGIN OPENSSH PRIVATE KEY-----), or Windows line endings from a text editor. To add a key correctly from a machine that can still log in with a password, use ssh-copy-id, which appends the key to the remote user's authorized_keys and creates the file and directory if needed:
ssh-copy-id -i ~/.ssh/id_ed25519.pub deploy@203.0.113.10
Fix ownership and permissions on the server
This is a very common server-side cause. sshd's StrictModes setting, which is on by default, checks the modes and ownership of the user's files and home directory before accepting a login. Typical triggers are a home directory set to 777, or a .ssh folder created with sudo so that root owns it. Fix it as root, replacing deploy with the real user:
sudo chown -R deploy:deploy /home/deploy/.ssh
sudo chmod go-w /home/deploy
sudo chmod 700 /home/deploy/.ssh
sudo chmod 600 /home/deploy/.ssh/authorized_keys
Do not turn off StrictModes to make the error go away. The manual explains it exists because people sometimes leave their directory or files world-writable by accident, which would let another user add their own key.
Check the effective sshd settings
sshd -T prints the configuration sshd will actually use, after every included file. That matters on Ubuntu, where /etc/ssh/sshd_config includes files from /etc/ssh/sshd_config.d/, and for each keyword the first value sshd reads wins. A cloud-init or hardening file there can override what you see in the main file.
sudo sshd -T | grep -i -E 'pubkeyauthentication|authorizedkeysfile|permitrootlogin|allowusers|allowgroups|pubkeyacceptedalgorithms'
Check that:
pubkeyauthentication yes(the default).authorizedkeysfilestill points at.ssh/authorized_keys, unless you moved keys on purpose.permitrootloginis notnoif you are logging in as root. The default,prohibit-password, allows root with a key but not with a password.- If
allowusersorallowgroupsappears, your user is listed.
After any change, test the syntax and reload. Keep your current session open and test from a second terminal:
sudo sshd -t && sudo systemctl reload ssh
Windows Server as the SSH server
On Windows with the built-in OpenSSH Server, accounts in the Administrators group do not use the per-user authorized_keys file. Microsoft's key management guide puts their keys in C:\ProgramData\ssh\administrators_authorized_keys, with access limited to Administrators and SYSTEM, which its example sets with icacls:
icacls.exe "C:\ProgramData\ssh\administrators_authorized_keys" /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"
A key placed in C:\Users\Administrator\.ssh\authorized_keys for an admin account is a common reason key login fails on a Windows server. On a Windows install in another language, Microsoft's example uses the Administrators group's SID, *S-1-5-32-544, in place of the group name.
git@github.com: Permission denied (publickey)
The same error from Git means GitHub did not accept any key your computer offered. GitHub's troubleshooting page covers the causes; the main checks are:
- Test the connection directly. Run
ssh -T git@github.com. A working key returns a greeting with your username. Usessh -vT git@github.comto see which keys were offered. - Always use the
gituser. The remote must begit@github.com:owner/repo.git, not your own username. - Make sure a key is loaded.
ssh-add -l -E sha256lists the keys in your agent with fingerprints you can match against the SSH keys page in your GitHub settings. - Do not use
sudo git. GitHub notes that if you made your key without sudo and then runsudo git push, you are not using the key you generated, because root has its own~/.ssh.
On a server that pulls code during deployment, the key must belong to the user that runs git, for example www-data or deploy, and be added to GitHub as a deploy key or to a machine account.
Common mistakes
- Logging in as the wrong user. Many images expect
root,ubuntuor a user you created. The key is tied to one account. - Creating
.sshwith sudo. The folder ends up owned by root and StrictModes rejects it. - Pasting the private key on the server. Only the
.publine goes intoauthorized_keys. If you pasted a private key anywhere public, create a new key pair. - Turning password login back on as the fix. It hides the real fault and reopens the server to password guessing.
- Editing only the main sshd_config. A file in
sshd_config.dmay override it. Check withsshd -T. - Reloading sshd with a broken config and closing your only session. Always run
sshd -tfirst and keep a session or console open.
On a Bigdomainhost VPS
When you deploy a Bigdomainhost KVM VPS, you paste your SSH public key at order time and log in as root with that key once the server is ready; as our docs explain, this keeps password login off from the first boot. If you later get "Permission denied (publickey)", for example after adding a new user or replacing your laptop, open the out-of-band console in the control panel. It works without SSH, so you can fix authorized_keys or permissions from there and follow the server-side steps above. Every VPS comes with full root access, so nothing in this guide needs a support ticket.
If you are still stuck, send your ssh -v output, with IP addresses removed, to us on WhatsApp at any time, or call during IST working hours.
Bigdomainhost wrote this guide with AI assistance and sells the VPS servers it mentions. OpenSSH behaviour was checked against the OpenBSD manual pages and OpenSSH release notes on 28 November 2026; defaults can change between versions, so check man sshd_config on your own system.
Sources (checked )
- OpenBSD manual pages: ssh(1): -v, -i and file permissions for keys and config
- OpenBSD manual pages: ssh_config(5): IdentityFile and IdentitiesOnly
- OpenBSD manual pages: sshd_config(5): AuthorizedKeysFile, StrictModes, PermitRootLogin, MaxAuthTries
- OpenBSD manual pages: sshd(8): the -t and -T test modes
- OpenSSH: OpenSSH 8.8 release notes (RSA/SHA-1 signatures disabled by default)
- Ubuntu: openssh-server package in Ubuntu 24.04 (noble)
- Ubuntu Manpages: ssh-copy-id(1) for Ubuntu 24.04
- GitHub Docs: Error: Permission denied (publickey)
- Microsoft (Internet Archive copy): Key-based authentication in OpenSSH for Windows