Thursday, March 17, 2016

ssh: ProxyCommand via persistant ControlMaster connection

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)


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...