Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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