I want to determine the target address of an SSH connection with a function call that generate the address to connect to. All of the examples using ProxyCommand
that I can find online use the -W
flag to hop to a second machine. I tried that with localhost
for the second machine, and that worked but required SSH authentication twice which I didn't like.
I am trying to call ssh
inside of the ProxyCommand
without forwarding to second hop. Right now, I have in my .ssh/config
file:
Host test
ProxyCommand ssh user@address
When I do ssh test
, it seems to connect okay but after connecting there is a blank prompt that does not respond to input, so it seems stdin/stdout must not be directed properly.
Related questions:
Use a dynamically obtained hostname with an ssh config entry
How to get HostName from executable script in SSH config file?
man ssh_config
-W
is to forward the existing connection instead of opening a new one. You were asked to authenticate twice precisely because you didn't use-W
. Anyway, it isn't clear what you want to do and how that differs from using-W
.-W
. I wantssh test
to connect as though as I had enteredssh user@address
when I have the given block in.ssh/config
. (And I can't just putaddress
in theHostName
entry because I want to replace it with$(generate_address)
that will generate the address dynamically when ssh is called.ssh-agent
then.HostName
, and the address of machine C to thessh
command in theProxyCommand
line.