Basic ssh tunneling through generic linux ssh server/client

2

5

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

    ssh -p 2424 user@corporatehost.com

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?

Oleg

Posted 2010-09-19T12:51:55.987

Reputation: 113

Answers

1

Set up user@corporatehost.com as a proxy:

ssh -o 'ProxyCommand ssh -p 2424 user@corporatehost.com 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 user@corporatehost.com 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.

Gilles 'SO- stop being evil'

Posted 2010-09-19T12:51:55.987

Reputation: 58 319

1

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

ssh -p 2424 -t user@corporatehost.com  ssh internalcorporatehost

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

fgysin reinstate Monica

Posted 2010-09-19T12:51:55.987

Reputation: 2 228