With ssh -vvv user@host.com
you can get the debug output and it will probably tell you that it can't authenticate with ~/.ssh/id_rsa
(ssh's default key file). The answer is to tell ssh which key to use:
ssh -i /home/user/.ssh/KEY user@host.com
You can also add your per-host keyfile to your .ssh/config
, then you'll just have to type ssh host.com
and user/key are selected automatically.
Example entry for .ssh/config (For more information see man ssh_config
):
Host mysshserver ssh.host.com
HostName ssh.host.com
User myusername
IdentityFile ~/.ssh/mykeyfile
Explanation of keyfiles from man ssh
:
-i identity_file
Selects a file from which the identity (private key) for RSA or
DSA authentication is read. The default is ~/.ssh/identity for
protocol version 1, and ~/.ssh/id_rsa and ~/.ssh/id_dsa for pro‐
tocol version 2. Identity files may also be specified on a per-
host basis in the configuration file. It is possible to have
multiple -i options (and multiple identities specified in config‐
uration files).
I'm getting a bad configuration option when adding the ssh -i line:
/home/gabriel/.ssh/config: line 2: Bad configuration option: ssh – Gabriel A. Zorrilla – 2010-09-12T20:48:49.157
@Gabriel: "ssh -i /home/user/.ssh/KEY user@host.com" works only from the commandline. The configfile option is different and I've updated my answer with an example entry for the .ssh/config file. – None – 2010-09-12T21:01:54.810