0

Possible Duplicate:
Forward SSH traffic through a middle machine.

I am looking to get an interactive ssh session on a remote machine, but must login via a gateway.

For example, right now I do the following:

@local % ssh <user>@<gateway>

@gateway % ssh <user>@<remote>

Is it possible to achieve the same thing in a single command from my local machine? I have tried:

@local % ssh <user>@<gateway> 'ssh <user>@<remote>`

From the output i am indeed able to login, but do not get an interactive session. I took inspiration for this attempt from using ssh to run a command remotely.

dtlussier
  • 2,165
  • 2
  • 23
  • 28

1 Answers1

4

One way:

On your "gateway"...

vi ~/.ssh/config
Host remote
   ProxyCommand ssh -C gateway '/usr/bin/nc <remote.ip.address> 22'

On "local"...

$ ssh -t user@gateway 'ssh user@remote'
Matt
  • 406
  • 2
  • 5
  • Thanks - I'd rather not make changes to the gateway machine as I have limited ability to access it beyond ssh login. I am not expert in the ways of modifying ssh config files so for me I'd rather make changes locally so that I can easily undo them in the event they don't work. A local solution is suggested in http://superuser.com/questions/107679/forward-ssh-traffic-through-a-middle-machine as suggested by Gilles. – dtlussier Sep 06 '10 at 21:14