ssh passwordless login fails with permission denied (publickey)

ssh permission denied (publickey mac)
wsl ssh permission denied (publickey)
ssh port forwarding permission denied (publickey)
sftp permission denied (publickey)
etc/ssh/sshd_config: permission denied
ssh-copy-id permission denied (publickey)
linode permission denied (publickey)
permission denied (publickey,password)

I am trying to set up passwordless ssh on two fresh linux VM's from VM A to VM B but I'm having permissions issues. I installed openssh-server on both vm's and configured /etc/ssh/sshd_config as follows:

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys
PasswordAuthentication no

All other fields are their default values. On VM A I ran ssh-keygen -t rsa with the default options. I tried to use ssh-copy-id but I got a permission denied(publickey) error. I then manually copied id_rsa.pub into authorized_keys on VM B. I used chmod 700 for ~/.ssh, chmod 600 for ~/.ssh/id_rsa, and chmod 644 for ~/.ssh/id_rsa.pub, ~/.ssh/authorized_keys, and ~/.ssh/known_hosts on both VM's. After running ssh -v VM-B I get the following output:

OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to hadoop-slave-1 [192.168.86.134] port 22.
debug1: Connection established.
debug1: identity file /home/hduser/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/hduser/.ssh/id_rsa-cert type -1
debug1: identity file /home/hduser/.ssh/id_dsa type -1
debug1: identity file /home/hduser/.ssh/id_dsa-cert type -1
debug1: identity file /home/hduser/.ssh/id_ecdsa type -1
debug1: identity file /home/hduser/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 45:48:fd:f0:db:1a:2a:c0:80:17:ec:18:5a:dd:f2:a5
debug1: Host 'hadoop-slave-1' is known and matches the ECDSA host key.
debug1: Found key in /home/hduser/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/hduser/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/hduser/.ssh/id_dsa
debug1: Trying private key: /home/hduser/.ssh/id_ecdsa
debug1: No more authentication methods to try.
Permission denied (publickey).

Is there something else I need to do?

try to follow Password-less logins with OpenSSH

in particular this should work:

ssh-copy-id -i ~/.ssh/id_rsa.pub username@mystery

This will prompt you for the login password for the host, then copy the keyfile for you, creating the correct directory and fixing the permissions as necessary

SSH passwordless root login gets "Permission denied (publickey , The problem was the ssh command was calling the pi user, not the root one, so, the checked authorized_keys was the one in /home/pi/.ssh , not� When executing ssh command like below to login to a ssh server, a permission denied messsage occurs. Raw. $ ssh ssh-server Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password,hostbased). With "-vv" option shows some debug information. Raw.

Another cause of permission issues is the permissions set on the home directory. Check if this is 755 or less.

See http://www.openssh.org/faq.html#3.14 for more details.

SSH Won't login permission denied (publickey,password , SSH Won't login permission denied (publickey,password) Is there a way to reset ssh and start over without damaging the server cat ~/.ssh/id_rsa.pub | ssh <user>@<hostname> 'cat >> .ssh/authorized_keys && echo "Key copied"' We had the same problem as we no longer use our developer but he� try to follow Password-less logins with OpenSSH. in particular this should work: ssh-copy-id -i ~/.ssh/id_rsa.pub username@mystery This will prompt you for the login password for the host, then copy the keyfile for you, creating the correct directory and fixing the permissions as necessary

This line in the log you posted doesn't look right:

debug1: Offering RSA public key: /home/hduser/.ssh/id_rsa

Could you try:

ssh-copy-id remotemachine_username@remotemachine

I get the error 'Permission denied (publickey)' when I connect with , If you're getting the Permission denied (publickey) error when connecting to your Your key isn't listed in the authorized_keys file on the Linode (or the file doesn't exist). Use Public Key Authentication with SSH - Linode FROM CLIENT - Copy public key to server: ssh-copy-id user@server Client public key will be copied to server's location ~/.ssh/authorized_keys. FROM CLIENT - Connect to server: ssh user@server; Now, if it's still not working after the described 3 steps, lets try the following: Check ~/ssh folder permissions in client and server machine.

try to change the PasswordAuthentication no to yes

server - SSH Permission denied (publickey), Sometimes the issue comes from permissions and ownership. For instance, if chmod 700 .ssh chmod 600 .ssh/authorized_keys. share. Share a AllowGroups ssh #Here only users of 'ssh' group can login. share. Share a� Check that key-based authentication is allowed by the server. Make sure the private key is readable by the SSH client. If you're using PuTTY, make sure your SSH keys are properly configured for the session. If you're using an OpenSSH client, be sure your private SSH key has the proper permissions.

SSH login using public key failed, Whenever encountering a problem ssh'ing to a server, it's always best to add the id_rsa.pub ) should be added to the "remote user's .ssh/authorized_keys" file. directory permissions are not the same kind of permissions error can crop up. Make sure the server has your PUBLIC key (.pub). Make sure your IdentiyFile points to your PRIVATE key. Make sure your .ssh directory has 700 and your files are 700 permissions (rwx------). If you have many key files, try IdentitiesOnly yes to limit the authentication to use the single, specified key.

SSH permission denied on correct password authentication, Server's /etc/ssh/sshd_config file: To enable password authentication, uncomment #PasswordAuthentication yes. To enable root login, uncomment The local script works, but the one for the remote Pi doesn't (error: "Permission denied (publickey)." It does work if run it as normal user. Again, it doesn't work if run it with sudo , from the shell.

Troubleshoot "Permission Denied (Publickey)" or "Authentication , try to follow Password-less logins with OpenSSH. in particular this should work: ssh-copy-id -i ~/.ssh/id_rsa.pub username@mystery. This will prompt you for the � SSH command use wrong key. Sometimes the command for SSH connection will try to use wrong key if you have more than one. This can be solved by adding the key to the list of ssh keys: ssh-add ~/.ssh/correct_private_key. Now correct_private_key will be correctly associated with your connection ( by using IdentityFile).

521908, "Permission denied (publickey)" and "Authentication failed, on the instance and the correct SSH public key is in the authorized_keys file.

Comments
  • When debugging sshd access issues, I often find that it helps to run sshd on the remote machine in non-daemon mode, e.g. sshd -D -d -p 8022. Then ssh -p 8022 remotehost from the other machine. sshd tends to produce more informative error output than ssh does.
  • I had tried this before and had a permissiondenied(publickey) error but this worked when I re-enabled password authentication temporarily. I also had to use ssh-add before using ssh-copy-id which I had neglected to do before.
  • FYI, I created a small script at github.com/centic9/generate-and-send-ssh-key which runs the necessary steps in one go and additionally ensures all the file/directory permissions which always caused me headaches...
  • I am facing same issue could you please help in this.
  • Just so you know: on IBM AIX this doesn't work because there is no ssh-copy-id. chmod -R 755 ~/.ssh works fine though.
  • This could easily by a comment.