3

I would like to be able to use locally added ssh key to agent on remote host without calling ssh-add on remote.

john@john-VirtualBox:~$ ssh-add ~/.ssh/ansusersu_rsa
Enter passphrase for /home/john/.ssh/ansusersu_rsa: 
Identity added: /home/john/.ssh/ansusersu_rsa (ansusersu@galaxy)
john@john-VirtualBox:~$ ssh [email protected] 'sudo whoami'
root
john@john-VirtualBox:~$ ssh [email protected] 'sudo whoami'
root
john@john-VirtualBox:~$ ssh [email protected] 'ssh [email protected] '"'"'sudo whoami'"'"''
Host key verification failed.

What I mean, after I loaded key to agent I'm able to connect to both hosts 192.168.0.3 & 192.168.0.2. When I execute a command on 192.168.0.3 in there I do some access to 192.168.0.2 and now it shows "Host key verification failed", but I would like to make it work. Is it possible to make it work? In reality I need to do on 192.168.0.3 rsync of a folder from 192.168.0.2.

1 Answer 1

1

Host key verification failed.

says that the authenticity of server 192.168.0.2 was not verified, because it's host key is not in the known_hosts of 192.168.0.3. So first of call, manually connect to the 192.168.0.3 and from there to 192.168.0.2 and verify the host key.

Then you can use ssh-agent forwarding (-A switch):

ssh -A [email protected] 'ssh [email protected] sudo whoami'
2
  • Thank you very much. I was about to answer my question. Another option to "-A" is to add into ~/.ssh/config 2 lines: "Host * ForwardAgent yes ". But that option is not good from security point Dec 25, 2016 at 15:54
  • Yes, enabling that for all the hosts is not a good idea.
    – Jakuje
    Dec 25, 2016 at 15:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .