LinuxQuestions.org
Have you listened to LQ Radio?
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
Thread Tools Search this Thread
Old 03-04-2009, 07:26 AM   #1
jackd1000
Member
 
Registered: Jul 2007
Posts: 39
Thanked: 0
ssh port forwarding


[Log in to get rid of this advertisement]
I'm trying to forward a port through an SSH tunnel between two red hat 5.3 hosts.

I assume that I need to the following :-

i) on the 'client' side

ssh -L 15210:destination_host:1521

ii) on the 'server' side I need to do a similar thing , except redirecting the other way

Is this kind of right ? What are the exact arguments to 'ssh'? And what is the difference between running 'ssh -L' and 'ssh -R' ?

Yours in anticipation
Jack
jackd1000 is offline     Reply With Quote
Old 03-04-2009, 07:36 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 33,839
Thanked: 223
the client command seems fine, you need to do nothing at all on the server side.

L does client to server forwarding, R does server to client forwarding
acid_kewpie is offline     Reply With Quote
Old 03-04-2009, 08:26 AM   #3
jackd1000
Member
 
Registered: Jul 2007
Posts: 39
Thanked: 0

Original Poster
I have now got the client side running fine.
On the server I have a daemon process listening on port 1521 and I want these coming back on 15210, naturally, as that is the port of my client side process.

However if on the 'client' side I run

ssh -R 1521:localhost:15210 user@serverhost

I get a problem as my daemon is already listening on 1521. How do I make sure that my server side port 1521 responses get to my client side 15210 port ?
jackd1000 is offline     Reply With Quote
Old 03-04-2009, 09:45 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 33,839
Thanked: 223
they don't get to that port, I think you're misunderstanding something. When your client connects to 15120 it establishes a fully stateful TCP session with the remote SQL box, just like if you connected directly to it. No return data needs to be sorted at all.
acid_kewpie is offline     Reply With Quote
Old 03-04-2009, 10:46 AM   #5
jackd1000
Member
 
Registered: Jul 2007
Posts: 39
Thanked: 0

Original Poster
Chris

many thanks for your previous email.

I'm still getting problems.

I am running, on my client machine, a port forwarder interactively :-

**

ssh -v -L 15210:db_server:1521 -N orcl@db_server
oracle@db_server's password:
debug1: Authentication succeeded (password).
debug1: Local connections to LOCALHOST:15210 forwarded to remote address db_server:1521
debug1: Local forwarding listening on 127.0.0.1 port 15210.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on ::1 port 15210.
debug1: channel 1: new [port listener]
debug1: Entering interactive session.

**

I then try to connect to my db_server from the client machine and I get :-

**

debug1: Connection to port 15210 forwarding to db_server port 1521 requested.
debug1: channel 2: new [direct-tcpip]


**


From what I can tell this is about as far as I can get. My server process I know is not receiving any connection requests.

How do I debug the server side ? What are the likely causes of things not working properly ?


Regs
JAck
jackd1000 is offline     Reply With Quote
Old 03-04-2009, 11:33 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 33,839
Thanked: 223
on the tunnel, specify 127.0.0.1 instead of the external host name. This name is as resolved by the REMOTE machine, so 127.0.0.1 will be the loopback interface on the server.
acid_kewpie is offline     Reply With Quote
Old 03-05-2009, 05:58 AM   #7
jackd1000
Member
 
Registered: Jul 2007
Posts: 39
Thanked: 0

Original Poster
Chris

You are a genius, it works just fine.

Regs
Jack
jackd1000 is offline     Reply With Quote

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
SSH Port Forwarding dylans Linux - Software 1 01-09-2009 11:28 PM
Port Forwarding with SSH jeremy LQ Articles Discussion 2 03-14-2008 12:16 PM
ssh and port forwarding mezeq Linux - Networking 2 11-06-2006 02:29 PM
SSH Port forwarding WRSpithead Linux - Networking 1 04-18-2005 05:09 AM
ssh, and port forwarding Tricky Linux - Networking 3 01-06-2003 08:50 PM


All times are GMT -5. The time now is 06:09 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.
Advertisement
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Click Here to receive a complimentary subscription courtesy of LQ.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration