SSH Permission denied (publickey) - Rocketeers app

  [ Rocketeers ](/)   

[Login](https://rocketeersapp.com/login) 

 On this page

 Knowledge
---------

SSH Permission denied (publickey)
=================================

### [\#Hosting](https://rocketeersapp.com/knowledge/hosting)

This SSH error means the server rejected every key your client offered. Usually the right key is not being sent, or the file permissions on the server are wrong.

 Published by [Mark van Eijk](https://rocketeersapp.com/author/mark-van-eijk) on June 23, 2026 · 1 minute read

1. [About the error](#content-about-the-error)
2. [Why do I see this error](#content-why-do-i-see-this-error)
3. [Solution](#content-solution)
4. [Diagnose first](#content-diagnose-first)
5. [Make sure your key is on the server](#content-make-sure-your-key-is-on-the-server)
6. [Offer only the right key](#content-offer-only-the-right-key)
7. [Fix permissions on the server](#content-fix-permissions-on-the-server)

[\#](#content-about-the-error "Permalink")About the error
---------------------------------------------------------

Connecting over SSH fails with:

 ```
Permission denied (publickey).

```

The server only accepts public-key authentication, and none of the keys your client presented matched an entry in the account's `authorized_keys`. A related variant, `Too many authentication failures`, means your client offered so many wrong keys that the server cut you off before reaching the right one.

[\#](#content-why-do-i-see-this-error "Permalink")Why do I see this error
-------------------------------------------------------------------------

- Your public key isn't in the server's `~/.ssh/authorized_keys`.
- The client is offering the wrong key, or every key in your agent.
- File permissions on the server's `.ssh` directory or `authorized_keys` are too open, so sshd ignores them.
- You're connecting as the wrong user.

[\#](#content-solution "Permalink")Solution
-------------------------------------------

### [\#](#content-diagnose-first "Permalink")Diagnose first

Verbose output shows exactly which keys are offered and how the server responds:

 ```
ssh -vvv user@your-server

```

### [\#](#content-make-sure-your-key-is-on-the-server "Permalink")Make sure your key is on the server

The easiest way to install your public key is `ssh-copy-id`:

 ```
ssh-copy-id user@your-server

```

Or append it manually to `~/.ssh/authorized_keys` on the server.

### [\#](#content-offer-only-the-right-key "Permalink")Offer only the right key

If you have many keys, the agent offers them all and can trip "Too many authentication failures". Force a single key and ignore the agent:

 ```
ssh -o IdentitiesOnly=yes -i ~/.ssh/id_ed25519 user@your-server

```

Make it permanent in `~/.ssh/config`:

 ```
Host your-server
    HostName your-server.example.com
    User deployer
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes

```

### [\#](#content-fix-permissions-on-the-server "Permalink")Fix permissions on the server

sshd refuses keys if the files are world-writable. The `.ssh` directory must be `700` and `authorized_keys` must be `600`, both owned by the account's user:

 ```
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chown -R $USER:$USER ~/.ssh

```

After fixing this, reconnect and the key should be accepted.

### Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

  Fill in your email address to receive updates  Subscribe 

#### More in [\#Hosting](https://rocketeersapp.com/knowledge/hosting)

- [How to get top processes with highest memory usage](https://rocketeersapp.com/knowledge/top-processes-memory)
- [How to get top processes with highest CPU usage](https://rocketeersapp.com/knowledge/top-processes-cpu)
- [How to add Swap Space on Ubuntu servers](https://rocketeersapp.com/knowledge/add-swap-space-on-ubuntu)
- [Disable unnecessary and unused PHP versions (FPM pools)](https://rocketeersapp.com/knowledge/disable-unused-php-fpm-pools)
- [Reclaim disk space on Ubuntu server](https://rocketeersapp.com/knowledge/reclaim-diskspace-on-ubuntu)
- [How to check Ubuntu version](https://rocketeersapp.com/knowledge/ubuntu-version)

 [View all 16 articles →](https://rocketeersapp.com/knowledge/hosting)
