LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-17-2011, 06:26 PM   #1
Consystor
LQ Newbie
 
Registered: Jul 2003
Location: Germany (BW)
Posts: 23

Rep: Reputation: 0
Question Accessing an SSH tunnel port which is created on another system


Hello together!

I've a server with
- a service port 2000 behind a firewall and
- an SSH service.

I've a mediator which can access the server via ssh.
So I can create a tunnel on the mediator:
user@mediator$ ssh -L 4000:localhost:2000 server

Now on the mediator I can connect to the port 4000 which is forwarded to server:2000 .

But the port 4000 of mediator isn't usable for other clients outside the system. Is it possible to change it that the port will be connectable by another clients, too. I mean like this:
user@client$ application mediator:4000

Many thanks for any help!

Regards
 
Old 11-17-2011, 09:29 PM   #2
cargofiend
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Rep: Reputation: Disabled
Wouldn't this work:

user@client$ ssh -f -L 4000:server:2000 mediator -N

then access the localhost:4000 with your app

http://www.revsys.com/writings/quick...sh-tunnel.html
 
Old 11-17-2011, 10:10 PM   #3
Consystor
LQ Newbie
 
Registered: Jul 2003
Location: Germany (BW)
Posts: 23

Original Poster
Rep: Reputation: 0
Your command
user@client$ ssh -f -L 4000:server:2000 mediator -N
wouldn't work because mediator can't access port 2000 of server directly (2000 is behind a firewall). It only can access port 22 of server and open a SSH tunnel to 2000.

But thanks for your help!

BTW:
The configuration is that mediator has no SSH server.
Otherwise the problem could be solved like this:

user@mediator$ ssh -L 4000:localhost:2000 server
user@client$ ssh -L 6000:localhost:4000 mediator
user@client$ application localhost 6000

(I write 2000, 4000, 6000 to see better which port number belongs to which other one).

Last edited by Consystor; 11-17-2011 at 10:12 PM.
 
Old 11-17-2011, 10:42 PM   #4
tollingalong
Member
 
Registered: Nov 2011
Posts: 42

Rep: Reputation: Disabled
The configuration is that mediator has no SSH server.

That would be a problem. You need SSH server running in order to accomplish this to the best of my knowledge.
If no one can SSH into your mediator then they cannot ssh tunnel.
 
Old 11-17-2011, 11:01 PM   #5
Consystor
LQ Newbie
 
Registered: Jul 2003
Location: Germany (BW)
Posts: 23

Original Poster
Rep: Reputation: 0
Hmm...
The question is if you can set ssh in such a way that clients from "outside" can access a port which is the "entering" port of a SSH tunnel.

In other words my overall question is:
If you open a SSH tunnel
user@mediator$ ssh <portm>:<host>:<porth> <server>
then _local_ clients on mediator can connect to <portm>.

But is there a possibility to make <portm> of mediator connectable for _remote_ clients, too?
 
Old 11-18-2011, 12:38 AM   #6
tollingalong
Member
 
Registered: Nov 2011
Posts: 42

Rep: Reputation: Disabled
client => mediator =>FW=> server

If I understand this properly.
1) You have access to get from the mediator to the server behind the firewall.
2) Clients are unable to SSH into mediator but you'd like them to ride a tunnel on some port; somehow.

If that's the case then to the best of my knowledge that cannot be done.
 
Old 11-18-2011, 03:52 AM   #7
Consystor
LQ Newbie
 
Registered: Jul 2003
Location: Germany (BW)
Posts: 23

Original Poster
Rep: Reputation: 0
@tollingalo
I think you understood it 100% right.
But I don't know how you mean "cannot be done".
Maybe you mean "cannot be done with the ssh client".

Statement:
I think technically in general it can be done.

Argumentation:
Because if mediator would have SSH, this would be possible - I've tested it:
user@mediator$ ssh -L 4000:localhost:2000 server
user@client$ ssh -L 6000:localhost:4000 mediator
user@client$ application localhost 6000

Implication:
So technically I see no limit to write a software which
1) would run on mediator
2) would map the only locally accesible port 4000 to a very normal also remotely accessible port 6000 which could be accessed by client


But maybe you mean that you don't know any software which could do that.
Maybe you're right. I also don't know anyone - hence I asked here.
Thanks for your help!

Maybe someone else has an idea?

Last edited by Consystor; 11-18-2011 at 04:29 AM.
 
Old 11-18-2011, 05:51 AM   #8
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Is there any firewall on mediator too, which blocks port 4000? Others should be able to use it. If it’s only available locally, you can check the setting GatewayPorts and set it to yes, so it will be available remotely.
 
1 members found this post helpful.
Old 11-18-2011, 06:10 AM   #9
Consystor
LQ Newbie
 
Registered: Jul 2003
Location: Germany (BW)
Posts: 23

Original Poster
Rep: Reputation: 0
Thumbs up

Hello Reuti!

The mediator has no firewall on 6000 (I think you meant 6000 because 4000 isn't used on the mediator).

So
GatewayPorts yes
in my
/etc/ssh/ssh_config
is exactly what I need.

Best regards and Many Thanks for your help!

Last edited by Consystor; 11-18-2011 at 06:12 AM.
 
  


Reply



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 tunnel on port 22 connection refused ashamanmiller DamnSmallLinux 2 12-10-2010 08:54 AM
ssh tunnel port forwarding andycol Linux - Server 2 03-18-2010 07:01 AM
Forward Port to SSH Tunnel Gerrit Jan Linux - Networking 1 03-18-2009 05:53 AM
Port Knocking through ssh tunnel metallica1973 Linux - Security 10 03-05-2008 09:00 PM
ssh tunnel / port forwarding Q FrayAdjacent Linux - Networking 2 07-05-2005 03:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:47 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration