Hi,
there are two common ways of doing this. I'll use your home, work, and gateway definitions here.
1. Set up a local tunnel using "ssh -L".
This makesd some high numbered port on your home machine forward to the sshd port on your work machine via a connection to the gateway. Then you ssh to that port on the home machine and the connection will go to the work machine.
Set up the tunnel. On home run:
Code:
ssh -t -L 9999:work:5903 gateway
This will create the tunnel and give you a terminal on the gateway machine.
Next, open a new terminal on home and run
Code:
ssh -p 9999 localhost
This will give you a shell on work.
2. Using proxycommand.
This is by far my preferred method. Basically you tell ssh how to hop from one machine to the next by putting some directives in your ~/.ssh/config
So you would add the following to ~/.ssh/config on home.
Code:
Host work
ProxyCommand ssh -qax -W %h:%p gateway
Port 5903
Thats it. Now you can just "ssh work" from home.
I think this method is far superior. You don't have to explicitly set up (and maintain) tunnels, you don't have to use some strange incantation (ie "ssh -p 9999 localhost") when you want to ssh to work, it works transparently with scp, rsync, sshfs etc.
Note also that if you have different usernames on the different machines you can also put them in the .ssh/config to save you needing to type that. For example if on home your username is alaios but at work you are alex, you can make your .ssh/config look like
Code:
Host gateway
User alex
Host work
User alex
ProxyCommand ssh -qax -W %h:%p gateway
Port 5903
HTH,
Evo2.