I created an RSA key but SSH keeps asking the password
Solution 1
Your key should go to .ssh/id_rsa
on the Mac, and id_rsa.pub
from the Mac should be added to the .ssh/authorized_keys
file on the server.
You should probably also chmod -R go-wr ~/.ssh
on the server.
Solution 2
OpenSSH tutorial explains how to resolve this problem.
Chances are, your
/home/<user>
or~/.ssh/authorized_keys
permissions are too open by OpenSSH standards. You can get rid of this problem by issuing the following commands:chmod go-w ~/ chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys
Solution 3
You want to connect to your Ubuntu Server without entering a password?
When you generate a new rsa keypair on your mac you end up with a private key (id_rsa
) and a public key (id_rsa.pub
). You'll find them in ~/.ssh/
by default.
Login into your ubuntu server and paste the content of id_rsa.pub
into ~/.ssh/authorized_keys
.
After this you should be able to connect without a password. On a standard ubuntu system you don't need to touch the sshd_config
at all.
Dan
Updated on September 18, 2022Comments
-
Dan over 1 year
On my Mac, I created an RSA key with
ssh-keygen -t rsa
and saved it as.ssh/authorized_keys
on the target server (Ubuntu).I put this in server's
/etc/ssh/sshd_config
:PubkeyAuthentication yes RSAAuthentication yes
and restarted SSH. However, it ignores the key. What's wrong?
-
Dan over 12 yearsYeah, the latter was the case. More details in my answer.
-
Dan over 12 yearsHi, thanks for the reply. Turned out, the problem was due to too loose permissions on the
.ssh
folder. -
Flash Sheridan about 11 yearsThe command should be: chmod -R go-wr ~/.ssh
-
VinGarcia almost 7 yearsFinally the answer I needed. Ssh should at least output a warning explaining the key was being ignored by the server of something like that.