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 ansusersu@192.168.0.3 'sudo whoami'
root
john@john-VirtualBox:~$ ssh ansusersu@192.168.0.2 'sudo whoami'
root
john@john-VirtualBox:~$ ssh ansusersu@192.168.0.3 'ssh ansusersu@192.168.0.2 '"'"'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

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 ansusersu@192.168.0.3 'ssh ansusersu@192.168.0.2 sudo whoami'
  • 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 – user1325696 Dec 25 '16 at 15:54
  • Yes, enabling that for all the hosts is not a good idea. – Jakuje Dec 25 '16 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.