LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 05-13-2007, 11:25 PM   #1
unknownmosquito
Member
 
Registered: Dec 2005
Distribution: Fedora 8
Posts: 57

Rep: Reputation: 15
how to do ssh trick?


Hey everyone.

I want to know if this is possible, and if so how to do it.

Say I have my machine, which wants to connect to a machine outside on the outside world. But it does not have sufficient permissions on the network. However, my machine can access a remote machine on the local intranet that can access the outside machine. How can I, in one command, ssh from my machine to the outside machine, such that I can do port forwarding on it as if I was connected directly.


So, visually:


[My machine] <--/--> [Outside machine]
[My machine] <-----> [Intranet machine]
[Intranet machine] <-----> [Outside machine]

How do I:

[My machine] <----[-I-n-t-r-a-n-e-t- -m-a-c-h-i-n-e]----> [Outside machine]

Thanks, hope I explained well enough..

Ian
 
Old 05-14-2007, 12:06 AM   #2
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 448

Rep: Reputation: 34
Using the -L switch to ssh:
Code:
ssh -L <localport>:externalserver:<port> intranetserver
Then just connect to localhost:<localport> and the connection will be forwarded via the SSH pipe, and the middle server will make the request on your behalf

Have a look here:
http://www.securityfocus.com/infocus/1816
 
Old 05-14-2007, 12:47 AM   #3
unknownmosquito
Member
 
Registered: Dec 2005
Distribution: Fedora 8
Posts: 57

Original Poster
Rep: Reputation: 15
Clever, but it still leaves a problem.

I need the -L option to be open, so I can use a command like this (i could do this before I lost these permissions/some software was updated and ssh got blocked by accident)

Code:
ssh -L someport:127.0.0.1:20 username@remotehost
That was my original command; I need to run that command, but through the intranet machine, as though the intranet machine was not there.
 
Old 05-14-2007, 01:21 AM   #4
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 448

Rep: Reputation: 34
I don't quite understand... Can you give us some more specific details to help me understand?
 
Old 05-14-2007, 01:38 AM   #5
unknownmosquito
Member
 
Registered: Dec 2005
Distribution: Fedora 8
Posts: 57

Original Poster
Rep: Reputation: 15
Yeah, sorry. I know it's confusing.

I have a friend running a service on port 20. I want to forward it (using ssh) to port 4444 on my machine, so that I can point some programs at it to access the service. I cannot make the connection directly because of the firewall in our intranet. Before I lost access over port 22 from my computer to the outside world (reasons unknown; happens to anyone using openSSH for some reason) the command:
Code:
ssh -L 4444:localhost:20 username@remotehost
worked great.

However, now I am isolated. I can connect to an intermediate server which can connect me to the remote server, as you decsribed like this:
Code:
ssh -L someport:remote_host:22 username@intermediate_host
if I am not mistaken.

Is there a way that I could do both of these at the same time? So that I can have my port forwarding through the intermediate host?

Last edited by unknownmosquito; 05-14-2007 at 01:40 AM.
 
Old 05-14-2007, 01:45 AM   #6
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 448

Rep: Reputation: 34
Right, getcha now...

I see 3 options:
1) Open 2 port forwards - one on each host - and daisy chain them. Slow and nasty and not what you're really after.
2) Use a different port for SSH between the primary hosts and leave the intermediate out of it.
3) Open your friends port 20 to public access instead of just localhost, then use firewall to restrict the hosts that are allowed to connect.

That's all I can think of - someone else probably has another alternative.
 
  


Reply

Tags
firewall, forward, local, port, remote, ssh


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
Trick Yum volvogga Linux - Newbie 4 08-18-2005 06:53 PM
!(last command) trick? belorion Linux - General 5 07-03-2005 02:01 PM
How to trick a router Citizen Bleys Linux - Networking 4 01-31-2002 02:09 PM
FDISK didn't do the trick d3funct Linux - General 8 11-08-2001 05:29 AM
Awesome X trick doodah Linux - General 6 06-01-2001 08:51 AM


All times are GMT -5. The time now is 08:23 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration