SSH exhausted every authentication method the server would accept without a successful login. Usually the right key isn't offered, isn't registered server-side, or the wrong user/key is being used.
SSH authentication is a multi-step process where the client and server negotiate which authentication methods are available and acceptable. This error appears after the SSH protocol handshake completes but authentication fails at the application level. The server has either rejected all authentication attempts (publickey, password, keyboard-interactive, etc.) or only allows methods the client cannot satisfy. When SSH says "No more authentication methods to try," it means the client has run out of credentials to offer the server: every key it had was rejected, and no other enabled method (such as password) was available to fall back on.
Use verbose SSH mode to see what authentication methods the server is offering and which keys your client is trying:
ssh -v [email protected]Look for lines like:
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: /home/user/.ssh/id_rsa
debug1: Authentications that can continue: publickeyThis tells you what the server will accept. If the server only lists publickey but you expected to use a password, password auth is disabled server-side. If you see SSH offering several keys in a row before the connection drops, you are likely hitting the server's MaxAuthTries limit (see step 8).
Check that your private key file exists and has correct permissions:
ls -l ~/.ssh/id_ed25519 ~/.ssh/id_rsa 2>/dev/nullA usable key should look like:
-rw------- 1 user group 411 Jan 15 10:30 /home/user/.ssh/id_ed25519If you have no key at all, generate one (Ed25519 is the modern default; use RSA 4096 only if you need compatibility with older servers):
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519If permissions are too open, SSH will silently refuse the key. Fix them:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519Instead of relying on SSH to find your key automatically, point it at the exact key:
ssh -i ~/.ssh/id_ed25519 [email protected]For a non-default key name or location:
ssh -i ~/.ssh/my-custom-key [email protected]For Git operations (works with GitHub, GitLab, Bitbucket, etc.):
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519 -o IdentitiesOnly=yes" git clone [email protected]:user/repo.gitFor SCP or rsync:
scp -i ~/.ssh/id_ed25519 file.txt [email protected]:/destination/
rsync -e "ssh -i ~/.ssh/id_ed25519" file.txt [email protected]:/destination/Adding -o IdentitiesOnly=yes ensures only this key is offered, which also helps avoid the MaxAuthTries problem in step 8.
If the server has no matching authorized key, you must register your public key. If you still have temporary password access:
ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]Or add it manually with correct permissions:
cat ~/.ssh/id_ed25519.pub | ssh [email protected] \
"mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"If you have no access to the server at all, you'll need to:
- Ask the server administrator to add your public key.
- Use a different authentication method that is enabled.
- For a cloud instance, use the provider's console/recovery flow (e.g. EC2 Instance Connect, a serial console, or attaching the volume to another instance) to install the key.
If you have a ~/.ssh/config file, verify it points at the correct identity for this host:
cat ~/.ssh/configA correct entry looks like:
Host example.com
HostName host.example.com
User myuser
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yesIf the IdentityFile path is wrong or the file doesn't exist, SSH may fall through to other keys and then run out of methods. Fix the path as needed.
If you don't have a config file yet, create one:
cat >> ~/.ssh/config << 'EOF'
Host example.com
HostName host.example.com
User myuser
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
EOF
chmod 600 ~/.ssh/configIf you rely on the SSH agent, confirm your key is loaded:
ssh-add -lThis lists the keys the agent currently holds. If your key isn't listed, add it:
ssh-add ~/.ssh/id_ed25519If the key is passphrase-protected, this prompts for the passphrase once.
On macOS, you can have the key loaded from the Keychain automatically by adding this to ~/.ssh/config:
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519A very common cause of this error is connecting as the wrong user. Cloud images ship with a specific default login user, and using the wrong one means none of your keys will be accepted.
# Amazon EC2 - Ubuntu AMI
ssh -i ~/.ssh/key.pem ubuntu@<ec2-public-ip>
# Amazon EC2 - Amazon Linux / RHEL
ssh -i ~/.ssh/key.pem ec2-user@<ec2-public-ip>
# Amazon EC2 - Debian
ssh -i ~/.ssh/key.pem admin@<ec2-public-ip>
# DigitalOcean / Linode default droplet (often root, unless you created another user)
ssh -i ~/.ssh/id_ed25519 root@<server-ip>
# Google Compute Engine (the username gcloud/OS Login assigns you)
ssh -i ~/.ssh/google_compute_engine <your-username>@<gce-public-ip>Check your provider's documentation for the correct default user on your image.
Note: managed Git hosts and PaaS platforms are NOT raw SSH shells, so the patterns above don't apply to them:
- GitHub / GitLab / Bitbucket only accept Git over SSH using a key in your agent (not a .pem). Test connectivity with ssh -T [email protected] (or [email protected] / [email protected]); a success returns a greeting, not a shell.
- Heroku has no SSH login; use heroku run bash -a <app> for a one-off dyno shell instead.
If your agent holds several keys, SSH offers them one by one. The server counts each as an attempt and, once it hits its MaxAuthTries limit (default 6), it closes the connection before SSH ever reaches the correct key, producing this error. Restrict SSH to just the right key:
ssh -o IdentitiesOnly=yes -i ~/.ssh/id_ed25519 [email protected]Or set IdentitiesOnly yes in the host's ~/.ssh/config block (see step 5).
Repeated failed attempts can also get your IP temporarily banned. If you have server access, inspect the auth logs:
# On the remote server
sudo tail -f /var/log/auth.log # Debian/Ubuntu
sudo tail -f /var/log/secure # RHEL/CentOS/FedoraLook for entries like:
sshd: Too many authentication failures for user
sshd: Connection closed by authenticating user user X.X.X.X port XXXX [preauth]And check for fail2ban / firewall blocks:
sudo fail2ban-client status sshd # is your IP banned?
sudo iptables -L -n # inspect firewall rulesIf you're locked out, wait for the ban window to expire or have the administrator unban your IP (e.g. sudo fail2ban-client set sshd unbanip <your-ip>).
MaxAuthTries and key exhaustion: SSH servers cap authentication attempts (default 6) to limit brute-force. When ssh-agent holds many keys, each offered key burns one attempt, and the server can disconnect before your valid key is tried. IdentitiesOnly yes (with an explicit IdentityFile) is the cleanest fix because it stops SSH from blindly offering every agent key.
Per-host keys: Use separate Host blocks in ~/.ssh/config so each server is offered only its intended key:
Host github.com
IdentityFile ~/.ssh/github_key
IdentitiesOnly yes
Host bitbucket.org
IdentityFile ~/.ssh/bitbucket_key
IdentitiesOnly yesPKCS#11 and hardware keys: With a hardware token or PKCS#11 module, the client may prefer those keys over your file-based key. Use IdentityFile plus IdentitiesOnly yes to control exactly which key is offered.
ssh-agent in tmux/screen: Detached tmux or screen sessions can hold a stale SSH_AUTH_SOCK, so the agent looks empty. Refresh it after reconnecting (tmux setenv -g SSH_AUTH_SOCK $SSH_AUTH_SOCK and re-source in panes, or restart the session) so ssh-add -l shows your keys.
SELinux contexts: On SELinux systems, a private key or ~/.ssh restored from backup may carry the wrong context, causing sshd or the client to skip it. Restore the default context with restorecon -Rv ~/.ssh rather than disabling SELinux.
Legacy ssh-rsa rejection: Newer OpenSSH disables the old ssh-rsa (SHA-1) signature algorithm by default. An older RSA key against a new server (or vice versa) can leave no acceptable method. Prefer migrating to an Ed25519 key; only re-enable ssh-rsa via PubkeyAcceptedAlgorithms +ssh-rsa as a temporary, host-scoped measure.
sign_and_send_pubkey: no mutual signature supported
How to fix "sign_and_send_pubkey: no mutual signature supported" in SSH
sign_and_send_pubkey: signing failed for RSA from agent: agent refused operation
How to fix "sign_and_send_pubkey: signing failed for RSA from agent: agent refused operation" in SSH
Bad owner or permissions on /home/user/.ssh/config
How to fix "Bad owner or permissions on .ssh/config" in SSH
Error connecting to agent: Connection refused
How to fix "Error connecting to agent: Connection refused" in SSH
bind: Address already in use
How to fix "bind: Address already in use" in SSH