How to fix No more authentication methods to try. in SSH

SSHINTERMEDIATEMEDIUMUpdated May 28, 2026· 566 views

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.

Quick fix

Fixes No more authentication methods to try.

ssh -v user@host.example.com
  1. Check which authentication methods the server accepts
  2. Verify your private key exists and is readable
  3. Explicitly specify the private key to use
  4. Add your public key to the remote server
ssh — error
ssh -v user@host.example.com
No more authentication methods to try.

What this error means

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.

Typical symptoms

  • SSH connection prompt appears then immediately closes with the error
  • Error occurs even though you believe you have valid credentials (keys or password)
  • Manual SSH attempts all fail consistently
  • Verbose SSH output shows 'Authentications that can continue: publickey' but connection still fails
  • Scripts or automation using SSH (Git, SCP, rsync) fail without prompting for a password
  • Connection is closed before any shell prompt appears

Common causes

  1. No matching SSH public key is registered on the remote server for your user account
  2. The private key SSH is offering doesn't match any authorized public key on the server
  3. SSH is offering too many identity files and the server cuts the connection (MaxAuthTries exceeded) before reaching the valid key
  4. The wrong SSH user is specified (e.g. root instead of ubuntu, or ec2-user instead of admin)
  5. The intended private key file is missing, unreadable, or its path is incorrect
  6. The ssh-agent isn't running, or the right key isn't loaded into it, and no IdentityFile is specified
  7. The server has disabled password authentication and only allows public-key auth (so a missing key leaves nothing to try)
  8. Private key permissions are too open (not 600), so SSH refuses to use the key
  9. The server is rate-limiting or temporarily blocking your IP (fail2ban, MaxAuthTries lockout)

How to fix "No more authentication methods to try."

1Check which authentication methods the server accepts

Use verbose SSH mode to see what authentication methods the server is offering and which keys your client is trying:

bash
ssh -v user@host.example.com

Look for lines like:

bash
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: /home/user/.ssh/id_rsa
debug1: Authentications that can continue: publickey

This 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).

2Verify your private key exists and is readable

Check that your private key file exists and has correct permissions:

bash
ls -l ~/.ssh/id_ed25519 ~/.ssh/id_rsa 2>/dev/null

A usable key should look like:

bash
-rw------- 1 user group 411 Jan 15 10:30 /home/user/.ssh/id_ed25519

If you have no key at all, generate one (Ed25519 is the modern default; use RSA 4096 only if you need compatibility with older servers):

bash
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519

If permissions are too open, SSH will silently refuse the key. Fix them:

bash
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519
3Explicitly specify the private key to use

Instead of relying on SSH to find your key automatically, point it at the exact key:

bash
ssh -i ~/.ssh/id_ed25519 user@host.example.com

For a non-default key name or location:

bash
ssh -i ~/.ssh/my-custom-key user@host.example.com

For Git operations (works with GitHub, GitLab, Bitbucket, etc.):

bash
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519 -o IdentitiesOnly=yes" git clone git@github.com:user/repo.git

For SCP or rsync:

bash
scp -i ~/.ssh/id_ed25519 file.txt user@host.example.com:/destination/
rsync -e "ssh -i ~/.ssh/id_ed25519" file.txt user@host.example.com:/destination/

Adding -o IdentitiesOnly=yes ensures only this key is offered, which also helps avoid the MaxAuthTries problem in step 8.

4Add your public key to the remote server

If the server has no matching authorized key, you must register your public key. If you still have temporary password access:

bash
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@host.example.com

Or add it manually with correct permissions:

bash
cat ~/.ssh/id_ed25519.pub | ssh user@host.example.com \
  "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.

5Check ~/.ssh/config for key configuration

If you have a ~/.ssh/config file, verify it points at the correct identity for this host:

bash
cat ~/.ssh/config

A correct entry looks like:

bash
Host example.com
    HostName host.example.com
    User myuser
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes

If 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:

bash
cat >> ~/.ssh/config << 'EOF'
Host example.com
    HostName host.example.com
    User myuser
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes
EOF

chmod 600 ~/.ssh/config
6Ensure SSH agent has your key loaded

If you rely on the SSH agent, confirm your key is loaded:

bash
ssh-add -l

This lists the keys the agent currently holds. If your key isn't listed, add it:

bash
ssh-add ~/.ssh/id_ed25519

If 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:

bash
Host *
    AddKeysToAgent yes
    UseKeychain yes
    IdentityFile ~/.ssh/id_ed25519
7Use the correct SSH user for the server

A 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.

bash
# 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 git@github.com (or git@gitlab.com / git@bitbucket.org); 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.

8Avoid offering too many keys (MaxAuthTries) and check for IP blocks

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:

bash
ssh -o IdentitiesOnly=yes -i ~/.ssh/id_ed25519 user@host.example.com

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:

bash
# On the remote server
sudo tail -f /var/log/auth.log        # Debian/Ubuntu
sudo tail -f /var/log/secure          # RHEL/CentOS/Fedora

Look for entries like:

bash
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:

bash
sudo fail2ban-client status sshd     # is your IP banned?
sudo iptables -L -n                   # inspect firewall rules

If 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>).

Advanced notes

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:

bash
Host github.com
    IdentityFile ~/.ssh/github_key
    IdentitiesOnly yes

Host bitbucket.org
    IdentityFile ~/.ssh/bitbucket_key
    IdentitiesOnly yes

PKCS#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.

Frequently asked questions

What does "No more authentication methods to try." mean?
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. ) or only allows methods the client cannot satisfy.
How do I fix "No more authentication methods to try."?
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.
What causes "No more authentication methods to try."?
No matching SSH public key is registered on the remote server for your user account The private key SSH is offering doesn't match any authorized public key on the server SSH is offering too many identity files and the server cuts the connection (MaxAuthTries exceeded) before reaching the valid key
Is the "No more authentication methods to try." error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading