2

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?

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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.