
The first time you see the message "Permission denied (publickey)", it is scary. It looks like everything is wrong: the address is wrong, the server hates you, your access does not work. That is not the case. That message is the server telling you, very clearly, how it wants you to log in. You just have to know how to read it.
It happened to me on Friday, November 27, while verifying access to a client's server before starting work on it on Monday the 30th. The attempt to log in with a password failed with that exact message. And that failure, which sounds like a closed door, was actually the most useful piece of information in the whole verification.
What logging in with a key means
Key authentication works with a pair of keys: a public one, which lives on the server, and a private one, which you keep. When you try to log in, the server gives you a challenge that can only be solved with your private key, and your computer solves it without sending any secret over the network. The password never travels: there is nothing to intercept and nothing to guess.
It is the standard method for managing servers, and for a good reason: a well-generated key is much longer than any password a person can remember, and it cannot be guessed by trying combinations. Servers on the internet receive password login attempts all day, every day, from automated programs that try one list after another. With passwords disabled, those attempts have nothing to try.
Why the server rejected the password
When the server answers "Permission denied (publickey)", what it is saying is: "I only accept the publickey method". The word in parentheses is the key to the whole message: it names the only method it accepts. It is not telling you that your user does not exist or that the server is down. It is telling you that you tried the wrong method.
In this case, the email with the access details included a password, and still the server ignored it completely. The password did not work for SSH, because the server has password authentication disabled. If you do not know how to read the error, you spend the morning trying passwords that will never work, and every failed attempt convinces you a bit more that something is broken, when in reality the server is working perfectly.
The key that did work
The key came in a ZIP attached to the email with the access details. It is an Ed25519 key, which is the modern type: short, fast and secure. And it has no passphrase, so the login went straight in, without asking for anything else.
Having no passphrase is convenient, but it has a price: whoever has the key file gets in. There is no second barrier. That is why I stored it with restricted permissions, so only I can read it, and I did not upload it anywhere or paste it into any chat. A key without a passphrase is looked after the way you look after your house key: you do not leave it just anywhere and you do not lend it without thinking.
How to know which method a server accepts
You do not have to guess. The server itself tells you in several ways. The first is the error message: the parentheses in "Permission denied (publickey)" name the method. The second is testing: if the password always fails the same way and the key gets in, you know the method. And the third is asking: whoever gave you the access can tell you that it is key-only, as the email said in this case. Ideally they tell you from the start, so you do not waste time finding out through errors.
The lesson
If you see "Permission denied (publickey)", do not keep trying the password. The server is not broken and your access is not wrong: it is telling you that it wants a key. Find the key, store it with restricted permissions, and log in with it. And if you are the one setting up a server, disabling passwords and allowing only keys is one of the simplest and most effective decisions to keep out the programs that try passwords all day. Get a quote on WhatsApp in 2 min



