Basic ssh tunneling through generic linux ssh server/client

I'm use my home pc to connect to the corporate server with ssh doing something like:

    ssh -p 2424 [email protected]

Then I log in remotely once more to another server in the corporate network:

    ssh internalcorporatehost

Can I set a ssh tunnel to do this in one step, or are there any other ways to do that?


Set up [email protected] as a proxy:

ssh -o 'ProxyCommand ssh -p 2424 [email protected] nc %h %p' internalcorporatehost

This is best used through an alias in ~/.ssh/config, so you can simply type ssh ich:

Host ich
HostName internalcorporatehost
User user_name_on_internalcorporatehost
ProxyCommand ssh -p 2424 [email protected] nc %h %p

nc is the netcat command, which must be installed on the gateway machine. If it's not available, install any of the versions floating around (you only need basic functionality). You may need to indicate the full path to the nc binary (e.g. /home/oleg/bin/nc).

If your ssh client is Putty, this answer at Stack Overflow should help.


A very easy solution is to just tunnel an SSH command through an other SSH command using the -t flag.

ssh -p 2424 -t [email protected]  ssh internalcorporatehost

Makes it very easy and you don't need any further config.