permission denied (public key)


Sorry for this old chestnut but I'm stuck on the above message. Following a hard disk failure, I can only access my linode via Lish. My server is secured with public / private keys but my local machine no longer contains its key. I've followed the Linode guide to create and upload keys. This did work on one of my linodes but not on the other. I've now deleted the .ssh folder on lish and have then followed the linode guide. Everything works until I scp the new key from my mac. That's when I get the above message. I've also tried to paste the key from my local machine via lish and I've tried a reboot.

Many thanks for any help.



8 Replies

You can find some useful info on the ubuntu forum: … -publickey">

Thanks for your response T-A. I went all through that discussion and several others elsewhere on the web without any success. I'm stuck here and can no longer ssh to my linode or use sftp. Is there any way of removing key pair authentication and then setting it up again? Should I contact Linode support about this issue?

Key pair authentication removal is as simple as editing out the line in .ssh/authorized_keys on the linode server (or remove the file altogether, if there's just one key or you want to just remove key authentication, full stop).

You can try logging in with tracing on: ssh -v Even better, start an sshd daemon on the server in debug mode, it's easiest if you run on an alternative port (unless you stop the regular daemon). Or in debug, and non-daemon mode (-D below).

On the linode server, from lish, as root: /usr/sbin/sshd -D -d -p 2222

(for port 2222, unless you want it to run on standard 22 - stop the regular sshd then)

Add more -d for more details. It's usually enough to figure out what's wrong, you can see as it tries various authentication methods, and hopefully why it won't accept your key authentication.

Wow! Thanks a lot for being so helpful here. From doing as you describe the server tries my private key and can't authenticate. That's because I can't upload my public key. When I try to scp it to the server it says permission denied (publickey). I've tried to paste the key in on Lish but that doesn't work. I've spent hours on this googling away so am pretty desperate now for any assistance.

I finally contacted Linode support and got the answer pretty quickly. Using Lish, I re-enabled password authentication temporarily and was able to upload the key.

Aha, catch-22 there.. you can't enable public key authentication until you have your key uploaded (unless you also keep password authentication enabled until then).

Yes indeed but I somehow managed to do it on my other linode which definitely has password authentication disabled.

I bet you forgot to restart the sshd daemon after you disabled password identification.. it's really the only possibility to transfer a file with scp w/password.


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct