LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-22-2011, 10:38 PM   #1
resuni
Member
 
Registered: Oct 2009
Location: Colorado, USA
Distribution: I use Arch btw
Posts: 142

Rep: Reputation: 12
"Inverse SSH"


I was wondering if there was a way to connect over ssh "backwards". For example, lets say there's a client connected to example.com via ssh from behind a router. Well you wouldn't be able to ssh to that client unless the proper ports were forwarded on the router right? So I'm wondering if there would be a way to connect to example.com through ssh then from there connect to the client using the already existing ssh connection. Thanks to any responders.

Regards,
Brad
 
Old 03-23-2011, 12:58 AM   #2
A.Thyssen
Member
 
Registered: May 2006
Location: Brisbane, Australia
Distribution: linux
Posts: 158

Rep: Reputation: 44
You can make a connection but not specifically ssh.

What you want is on the machine behind the firewall, run a ssh to some external client, but not to set up a ssh terminal link, but to set-up a port forward on the external client back to the normal ssh port on the firewalled machine.

Later on the extrnal client (or if you allow it, some other host to that port on the external client), you ssh to that previously setup 'local port forward' and hey presto you are connected to the normal ssh port of the firewalled machine.

Its basically a ssh into the firewall via a ssh port forward previously set-up from inside the firewall

You can not use this for laptops or things not permanently on the net, as the firewalled machine must set-up the port forward.

Though you could have that machine 'test' the port forward is running, and re-try setting it up at regular intervals. This way if you have a roaming laptop, (which has say a dynamic DNS) the port forward and be initialised and you can connect to your firewalled host.


Note the simplest way is to actually setup a proper port forward on your router. I do this, and as my home router has a port forward to port 22 on my home machine, but it is NOT port 22 on the router. As my router has dynamic dns I can login to my home machines no matter what IP it or I am on.

But if you can't do that try the port forward solution.
 
Old 03-23-2011, 06:31 AM   #3
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
In fact, it's a remote forward. Have a look at the -R option to ssh. You can use this set up port on the outside machines then. To keep it alive, you can think about autossh and using an ssh-key.
 
1 members found this post helpful.
Old 03-23-2011, 07:05 AM   #4
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
It is a little bit mind boggling as to which port is where, but this is a good short guide:

http://www.howtoforge.com/reverse-ssh-tunneling

Remember that you have to initiate the connection from the computer which is behind the firewall and everything to your computer. But then you have access from your computer to the host behind the firewall.

If your computer is also behind a firewall, then you need a third computer which is open for SSH to both of you. If you can keep straight what is remote and what is local, use this guide:

http://sleepyhead.de/howto/?href=ssh

jlinkels
 
1 members found this post helpful.
Old 03-23-2011, 11:32 AM   #5
resuni
Member
 
Registered: Oct 2009
Location: Colorado, USA
Distribution: I use Arch btw
Posts: 142

Original Poster
Rep: Reputation: 12
Thanks for all the great replies! I'll look into them all and reply to this thread if I have any more questions.
 
  


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
"Keep laptop running on lid close?" + "ssh via crossover cable?" FatalKeystroke Linux - Laptop and Netbook 7 03-11-2011 07:53 AM
SSH issue ""Server unexpectedly closed network connection" Errsta_Fonzarelli Linux - Software 12 05-24-2010 02:35 PM
Supplying "password" to "ssh" command paragkalra Linux - Networking 1 07-31-2008 05:19 AM
Why does "crond" sleep and "ssh" hung up? Chowroc Linux - Networking 0 01-12-2006 12:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:10 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