Since yesterday, each time I try to connect to an ssh server, I got asked for my password. What should I do to make SSH not ask for my password each time.
2 Answers
Put your public key in hostmachine:~/.ssh/authorized_keys
and make sure it has the appropriate permissions (use chmod 600
). See the man page, section AUTHENTICATION, for more details. Note that sshd maybe configured to disallow this method of login although I cannot fathom why.
-
Thank, that worked. However could you explain me why do I have to put it in authorized_keys and why it was working without it before.– Ben DJan 24, 2012 at 18:06
-
1The man page has the information in the AUTHENTICATION section. As to why it was working before hand, I cannot be sure without having root access to your machines and doing some forensics work. Jan 24, 2012 at 19:50
-
2You can also use ssh-copy-id in order to get your public key automatically copied to destination host, if you don't want/need to copy it manually.– CorenJan 25, 2012 at 8:27
Check directory permissions, and file permissions.
$HOME
can't be writeable by group or other.
$HOME/.ssh
needs to have 700
permissions, not readable, writeable or executable by group and other.
$HOME/.ssh/authorized_keys
to be not writeable or executable by anyone.
If you find that permissions aren't strict enough, try to figure out what caused the problem. Last time this happened to me, I had compiled PHP from scratch. Executing make install
as root (Slackware) changed the permissions and ownership of /
or /home
as I recall, and kept ssh from working with authorized_keys
and id_rsa.pub
files that had been in place and working for ages. You want to determine what caused the problem, as changed directory ownership and/or permission can happen because of a rootkit install or something like that.
-
This fixed it for me.. After fixing my permissions, I added it using 'ssh-add'.. after closing that terminal and re-opening it and doing 'ssh-add -l' (lower L) I could see my identity, which worked.. I could SSH to all my boxes without having to type my private key pass 300+ times a day!! Thank you! Dec 23, 2016 at 11:11
ssh-add -l
.