1

I have two servers, middle and remote. middle is used as a proxy to access remote. I've set up middle's ssh config so that it preserves connections to remote via ControlMaster, as follows

Host remote ControlMaster auto ControlPath ~/.ssh/%r@%h:%p ControlPersist yes

I've created a persistent connection from middle to remote. This is convenient because the authentication on remote is complex.

I'd like to set up my local ssh config so that I can ssh from localhost to remote via middle, reusing the connection created above. I can do this manually as ssh -t middle ssh remote, but I can't figure out a way to accomplish the same thing using the ProxyCommand option, which is especially annoying if I want to scp a file to remote.

ProxyCommands which do not work include

  • ssh middle -W remote:22 (does not reuse connection)
  • ssh middle -t remote (goes all the way to a shell, confusing my local ssh client, which is expecting to talk to sshd, not a shell)
1
  • have you tried ProxyCommand option with netcat? There are some similar answers around here.
    – Jakuje
    Sep 28, 2015 at 20:34

1 Answer 1

0

I think you misunderstand the whole ControlMaster mechanism in ssh. The idea is that the connection is reused on the LOCAL SYSTEM - that is, on the "middle" server. So, in essence, to reuse the connection, you would need to invoke ssh client on "middle". Like this:

ssh middle "ssh remote"

This will connect you to "middle" first, and then launch an ssh client there, to connect you to "remote". The second connection will, with correct ControlMaster configuration, reuse the existing, persistent, connection.

2
  • I know this works - I mention it in the question. What I'm looking for is a way to reuse the connection when using the middle server to connect to the remote server via ProxyCommand.
    – Bakkot
    Sep 28, 2015 at 22:57
  • Again, you're missing the point. ProxyCommand, by definition, is executed on the CLIENT. The ControlMaster mechanism uses a local socket, which can be red only by a process running on "middle". I'm sorry I can't give you want you want. :(
    – user65677
    Sep 29, 2015 at 3:44

You must log in to answer this question.

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