SSH Connection Problem
I can't login remotely via SSH, and am receiving this error:
Disconnected: No supported authentication methods available (server sent: publickey)
How do I fix this so I can access my Linode?
1 Reply
The error you're seeing is saying that either Public Key authentication is not configured on your Linode, or that there is no matching Private Key present on your local machine. Are you connecting from a computer other than the one you would normally use to connect to your Linode? If so, you will need to generate and install a new keypair in order to connect over SSH.
To complete the installation of a keypair, or to proceed with further troubleshooting, you can access your Linode using our out-of-band LISH console.
If this does not work, or if you have already generated a keypair and set it up on your Linode, then it's worth verifying permissions on the key, as well as your relevant SSHd settings. To do so, run the following commands via LISH:
ls -l ~/.ssh/authorized_keys
cat /etc/ssh/sshd_config | egrep 'PasswordAuth|PermitRoot'
The permissions on ~/.ssh/authorized_keys
should be -rw-------
(or 600), and it should be owned by your user and group:
$ ls -l ~/.ssh/
total 4
-rw------- 1 your_user your_group 754 Dec 25 22:07 authorized_keys
You can quickly correct all of those issues with a string of commands like:
chown <user>:<group> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
sed -i -e "s/PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config
sed -i -e "s/#PermitRootLogin no/PermitRootLogin no/" /etc/ssh/sshd_config
sed -i -e "s/PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config
sed -i -e "s/#PasswordAuthentication no/PasswordAuthentication no/" /etc/ssh/sshd_config