Ubuntu: SSH Permission denied (publickey)
Question: I have tried searching previous questions for answers to my question but all of
the answers that have been suggested previously haven't worked for me.
I am trying to connect to a linode (running ubuntu 12.04 LTS) from my local
machine (also running ubnutu 12.04 LTS)
I have create a private and public key on my local machine and copied my public
key to my linode's authorized_keys file. However whenever I try to ssh to my
linode I get the error message "Permission denied (publickey).
Its not a problem with how ssh is set up on my linode because I can ssh to it
from my Windows machine using key authentication.
In my .ssh directory on my local ubuntu machine I have my id_rsa and id_rsa.pub
files. Do I need to create an authorized_keys file on my local machine?
EDIT: This is what I get when I run ssh -vvv -i id_rsa [youruser]@[yourLinode]
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).
Solutions Sample (Please watch the whole video to see all solutions, in order of how many people found them helpful):
== This solution helped 13 people ==
You don't need authorized_keys on your client.
You must tell the ssh-client to actually use the key you generated. There are
several ways to do that. Just for testing type ssh -vvv -i .ssh/id_rsa
[youruser]@[yourLinode]. You will have to provide your passphrase every time
you want to connect to the server.
If that worked you can add the key to the ssh-agent with ssh-add .ssh/id_rsa
(you will have to provide the passphrase only once for this and it should work
as long as you don't logout/reboot)
== This solution helped 1 person ==
For those Putty users like me who came to this thread, you may also get this
error if you forgot to add user user@Ip !
Others being permission on key file chmod to 600)
ssh 1.1.1.1 -i /path/to/.pem file
Permission denied (publickey).`
ssh user@1.1.1.1 -i /path/to/.pem file
== This solution helped 1 person ==
This is what worked for me, the fix is not mine but I would rather write it
down here in case someone else has the same problem.
The original author posted it here: http://webdesignforidiots.net/2016/02/
digital-ocean-public-key-access-denied-on-existing-droplet/
sudo nano /etc/ssh/sshd_config
Replace this
UsePAM yes
IgnoreUserKnownHosts no
PasswordAuthentication no
With this
UsePAM no
IgnoreUserKnownHosts no
PasswordAuthentication yes
Save the file and restart ssh
reload ssh
ssh should work now asking for a password
With thanks & praise to God! With thanks to all the many who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music & music license: https://www.bensound.com/royalty-free-music | Images & images license: https://stocksnap.io/license and others | With thanks to user Todd (https://askubuntu.com/users/650810), user Teemu Leisti (https://askubuntu.com/users/38043), user site80443 (https://askubuntu.com/users/482945), user Pattle (https://askubuntu.com/users/169450), user muru (https://askubuntu.com/users/158442), user Mostafa Ahangarha (https://askubuntu.com/users/214264), user mau (https://askubuntu.com/users/31584), user Kent (https://askubuntu.com/users/567272), user Justin C (https://askubuntu.com/users/166418), user Jens Erat (https://askubuntu.com/users/167385), user iman (https://askubuntu.com/users/187689), user guntbert (https://askubuntu.com/users/134729), user Galapagos (https://askubuntu.com/users/805916), user earthmeLon (https://askubuntu.com/users/13247), user cmbind55 (https://askubuntu.com/users/446266), user canoodle (https://askubuntu.com/users/389558), user Buzut (https://askubuntu.com/users/292984), user Alex Punnen (https://askubuntu.com/users/423906), and the Stack Exchange Network (http://askubuntu.com/questions/311558). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything should be amiss at Roel D.OT VandePaar A.T gmail.com.
3 Comments