View the Most Wanted LQ Wiki articles.
Go Back > Forums > Linux Forums > Linux - Security
User Name
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.


  Search this Thread
Old 07-14-2010, 03:29 PM   #1
LQ Newbie
Registered: May 2006
Posts: 13

Rep: Reputation: 0
Reverse SSH tunnel

Does anyone know if it is possible to make the remote port in a reverse SSH tunnel listen on the regular network interface of the SSH server, and not just the loopback adapter on the remote system? The client is putty on a Windows machine, server is Ubuntu based (but can go with another OS if needed).

I basically need a system located on the same network as the SSH server to connect to a TCP port on the system that's running the SSH client. No matter what I do, I can only get it to listen on localhost. Thanks!
Old 07-14-2010, 03:53 PM   #2
Registered: Nov 2003
Location: Belgium
Distribution: Slackware
Posts: 153

Rep: Reputation: 23
man ssh

option -R shows that it is possible with a limitation on the server side where it has to listen the 'GatewayPorts' must be enabled in the sshd_config file.

Off course there is a way to get around this for ports above 1024 (unless you can login as root)

ssh -R 2020:localhost:20 server
# this creates a reverse tunnel from server to client
ssh -P 2020 -g 5900:localhost:5900 localhost
# make a connection from the server to the client via that reverse tunnel

both lines above contain localhost but that refers to the 'other host'

I didn't test this hack but I don't see why it wouldn't work.
The -g allows other host to connect to the port without having access to the sshd_config on that server.
1 members found this post helpful.
Old 07-14-2010, 09:11 PM   #3
LQ Newbie
Registered: May 2006
Posts: 13

Original Poster
Rep: Reputation: 0
Thanks, GatewayPorts is exactly what I needed!
Old 07-14-2010, 10:37 PM   #4
Senior Member
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Debian, OS X
Posts: 1,291

Rep: Reputation: 102Reputation: 102
Dear Edan,

Please mark this thread as SOLVED if your problem is resolved. You can see my signature for the exact steps.


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
LXer: remote control android, a reverse ssh tunnel LXer Syndicated Linux News 0 05-18-2010 11:50 AM
Reverse SSH tunnel active only from localhost andreag Linux - Networking 2 12-19-2006 03:05 AM
SSH reverse tunnel (lo only? why not eth0) Dinomight Linux - Networking 3 08-17-2006 10:44 PM
Reverse SSH Tunnel sniggleflop Linux - Security 1 10-13-2002 02:24 PM

All times are GMT -5. The time now is 08:02 PM.

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