LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-25-2007, 12:11 PM   #1
philosophia
Member
 
Registered: Jun 2006
Posts: 54

Rep: Reputation: 15
SSH Tunnel Through 2 machines?


I run an ssh tunnel so that i can connect to my sql server ssh

ssh -L1433:sql-dev:1433 -l user server.com

I'm currently at a remote location - I can't log onto server.com from here. But I can log onto server2.com, from which I can log onto server.com.

Is there a way I can tunnel through server2 in order to establish my tunnel to server.com so that I can connect from this remote location?
 
Old 06-25-2007, 12:14 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,408

Rep: Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965
you can do tunnels on two seperate connections, sure.
 
Old 06-25-2007, 12:29 PM   #3
philosophia
Member
 
Registered: Jun 2006
Posts: 54

Original Poster
Rep: Reputation: 15
how would this ssh command look? i'm having trouble getting my head around it.
 
Old 06-25-2007, 04:13 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,408

Rep: Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965
well nothing special, just another normal tunnel. assuming you want to acces a tcp port that is only reachable via a box which itself you can only reach via sshing to another

your client command: ssh -L 1234:localhost:2345 remotebox1
your ssh from remotebox1: ssh -L 2345:remotebox3:3456 remotebox2

so you then connect to localhost:1234 and that ends up hitting 2345 on the first box you ssh to. that traffic then gets forwarded from port 2345 on the box through the 2nd box and onwards to the third system which is runnign the service you actually want.

but then hang on... you can connect from your client to box1, that ssh connection doesn't necessarily need to do anything special as you can also presumably hit any port on the box, not just 22? assumign that that's the case, you only need to establish the tunnel on the 2nd command... "ssh -L 1234:remotebox3:3456 remotebox2" so you then connect to port 1234 on box1 (instead of the client machien itself as in the first example) and then direct to box 3.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to tunnel X over SSH DaneM Linux - Software 23 06-07-2008 08:17 AM
setting up an ssh soxy or local ssh tunnel from within an ssh soxy Mangenius Linux - Networking 0 03-05-2007 03:15 PM
ssh tunnel TroelsSmit Linux - Software 2 04-30-2004 03:30 PM
Ssh Tunnel tinaa Linux - Software 7 07-29-2003 07:52 PM
SSH tunnel? tarballedtux Linux - Networking 3 04-09-2002 03:52 PM


All times are GMT -5. The time now is 12:00 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration