0

This is my script that I have

ssh server1 << EOF
  ssh server2 << EOB
EOB
EOF

I am able to enter the password for server1 successfully, but then it just freezes for a couple seconds and outputs an error saying "Too many authentication failures". Can anyone help? I want to have nested SSH'es to automate some stuff I'm doing.

zyne
  • 1
  • 1
    The second `ssh` doesn't have access to your tty, so it's trying to read from the same `< EOF ... EOF` heredoc that the command itself is in. Can you use the proxy jump option (`ssh -J server1 server2`, or [via the `ProxyJump` config directive](https://serverfault.com/questions/954281/how-to-ssh-directly-to-target-via-jumphost-using-ssh-config-without-additional-s)) instead of nested heredocs? – Gordon Davisson Jun 11 '20 at 03:26
  • @GordonDavisson I am on debian linux and that -J option doesn't exist – zyne Jun 11 '20 at 13:28
  • What version of OpenSSH do you have? If it's at least 7.1, you should be able to use `ProxyJump` (either in your config file or with the `-o` option), and for older versions you can use `ProxyCommand` to get the same effect (though it's more complicated to use). See [OpenSSH: Proxies and Jump Hosts (at WikiBooks)](https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Proxies_and_Jump_Hosts#Old_Methods_of_Passing_Through_Jump_Hosts). – Gordon Davisson Jun 12 '20 at 20:01
  • 1
    What version of debian is that, I just tried stretch, buster and sid. They all support it. – Garo Jul 21 '20 at 10:46

1 Answers1

0

In the comments you mention that you have a old version of openssh that doesn't support -J yet.
(Think about upgrading, that is already a really old openssh)

As a replacement you can use ssh -t server1 ssh server2
(Do not forget the -t or your terminal input won't work)

Garo
  • 181
  • 1
  • 1
  • 6