I have generated a pair of private/pub RSA keys. The public key is added to the remote server, however, when I connect to the remote server via ssh, through using -v, I can see that my local client is not using the private key in ~/.ssh . How can I add the private key to be sure it is used for authentication?
Hers the verbose output on ssh auth:
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/nubela/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/nubela/.ssh/identity
debug1: Trying private key: /home/nubela/.ssh/id_dsa
debug1: No more authentication methods to try.
Heres the ls -al of my ~/.ssh
[nubela@localhost .ssh]$ pwd
/home/nubela/.ssh
[nubela@localhost .ssh]$ ls -al
total 36
drwx------ 2 nubela guest 4096 2009-11-11 12:28 ./
drwx--x--x 70 nubela guest 4096 2009-11-11 00:53 ../
-rw-r--r-- 1 nubela guest 1486 2009-11-11 12:25 2.ppk
-rw------- 1 nubela guest 604 2009-06-09 04:37 authorized_keys2
-rw------- 1 nubela guest 1743 2009-11-03 23:48 id_rsa
-rw-r--r-- 1 nubela guest 398 2009-11-03 23:48 id_rsa.pub
-rw-r--r-- 1 nubela guest 2803 2009-11-11 13:34 known_hosts
-rw------- 1 nubela guest 1743 2009-11-11 12:21 upperstorey
-rw------- 1 nubela guest 398 2009-11-11 12:21 upperstorey.pub
upperstorey is the private key that I want the ssh client to be used. How can I add it?
PS: using -i /path/to/privatekey works
Thanks!
Best Answer
So, when connecting to host
remotehost
, you want to use the key contained in upperstorey?You need to tell ssh to use it explicitly. The easiest way of doing so is adding the following block to your ~/.ssh/config:
This tells
ssh
to use that key when connecting to that host. Add any aliases to the Host line (i.e. remotehost, remotehost.remotedomain.com, etc)