LinuxQuestions.org
Review your favorite Linux distribution.
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 07-11-2003, 12:32 PM   #1
The sakkie
LQ Newbie
 
Registered: Jul 2003
Location: Netherlands
Distribution: Suse 8.1
Posts: 6

Rep: Reputation: 0
ssh behind a router


Hi all.

I have a problem with ssh'ing to a linux (suse 8.1) machine behind a router.

I have two suse machines: one 8.2 and one 8.1. The one (8.1) machine is on a lan behind a router, using an ADSL internet connection. The other is on a university network. I can easilly access the one on the university network (the 8.2 machine) from the one behind the router (the 8.1 machine). "ssh ip.at.univ.edu".

But I do not know how to do the reverse. I do not know what ip to use, i do not understand the netmask and lan IP and all the other terms I see floating around on the forums.

Can someone please help.

Thx
The Sakkie
 
Old 07-11-2003, 12:45 PM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
This might be wrong, but I *think* you've gotta set up port forwarding on your router to point to your LAN IP (eg. 192.168.0.1:22) and you'd use your external (ie. internet IP) to connect. For example, if you had xxx.xx.xx.xxx:23 forwarding to 192.168.0.1:22, you'd do ssh xxx.xx.xx.xxx:23. Sorry if that's not too clear and again, it might be wrong. Would need to look at your router's documentation to set up port forwarding.

Last edited by Nylex; 07-11-2003 at 12:46 PM.
 
Old 07-11-2003, 01:06 PM   #3
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 68
What Nylex is saying is right but depending on your router you may need to open the port as well as forward it.
 
Old 07-11-2003, 01:19 PM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Oh yeah, true. Lol.
 
Old 07-11-2003, 01:34 PM   #5
The sakkie
LQ Newbie
 
Registered: Jul 2003
Location: Netherlands
Distribution: Suse 8.1
Posts: 6

Original Poster
Rep: Reputation: 0
I have a "sitecom router 4s".
I think i know what you mean, there is an option in the routers configuration where you can write an aplication name, set it's type as "udp/tcp"; its incoming (start-finish) and outgoing (start-finish) ports.

examples of such applications are: paltalk, strcraft, etc. Is this where I have to set it up, and if so; what are the values i need to enter for the ports.

Thanx for your help
The Sakkie
 
Old 07-11-2003, 01:39 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 68
Yes - that is it. You need to forward port 22 to port 22 of your linux box on the inside of your lan. Like I said earlier there may be an option to open the port as well.
 
Old 07-11-2003, 01:57 PM   #7
The sakkie
LQ Newbie
 
Registered: Jul 2003
Location: Netherlands
Distribution: Suse 8.1
Posts: 6

Original Poster
Rep: Reputation: 0
I think i have done that. When I ssh from my university machine to the one behind a router, what ip address do I use? Just the router IP?

when i type in "who am i" while loged into my university machine from behind the router I get the following reply: Jul 11 18:30 (adslXXX.XXX.XXX.nl). but when i try to ssh to that adress, it does not work?

Any ideas?
Sorry if I ask a lot of stupid questions! :-)

The Sakkie
 
Old 07-11-2003, 02:01 PM   #8
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 68
Yes you should use the ip of the router. make sure that that is your IP address though and not a proxy or something.

You may also want to make sure that your ISP lets you accept connections on that port. Some ISPs block access to those and so oyou may need to use a higher port number.
 
Old 07-11-2003, 02:12 PM   #9
The sakkie
LQ Newbie
 
Registered: Jul 2003
Location: Netherlands
Distribution: Suse 8.1
Posts: 6

Original Poster
Rep: Reputation: 0
I still cant get it to work; I am sure about the IP adress, I got it from the router "software". But how is it possible that i can ssh "out" from the PC behind the router, but not "in"? Could it then still be the ISP?

The other problem that I have, i supose it has nothing to do with the current problem, is with the x-server. I cant get my graphic user interface to work; While ssh'ed into the university pc from behind the router, the graphics wont work. I have done this previously from other machines, not behind the router. The xhost +, etc is set. If this has no relevance, just ignore it. I just thought perhaps it also has something to do with blocked ports?
 
Old 07-11-2003, 02:14 PM   #10
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 68
Yes - the isp may still be blocking connections on port 22 to your machine.

I take it you mean exporting programs over ssh? Have you used export to set the display to use? eg:
export DISPLAY=ip.of.other.machine:0
 
Old 07-11-2003, 02:22 PM   #11
The sakkie
LQ Newbie
 
Registered: Jul 2003
Location: Netherlands
Distribution: Suse 8.1
Posts: 6

Original Poster
Rep: Reputation: 0
I dont usualy do that; but I tried it now, and it does not work;
xxx@xxx ~ % export DISPLAY=130.xx.xx.xx:0
xxx@xxx ~ % konqueror
konqueror: cannot connect to X server 130.xx.xx.xx:0

Any ideas? Does this also run through port 22?
 
Old 07-11-2003, 02:24 PM   #12
The sakkie
LQ Newbie
 
Registered: Jul 2003
Location: Netherlands
Distribution: Suse 8.1
Posts: 6

Original Poster
Rep: Reputation: 0
PS. you said I could use a higher port number...
How do I do that?
 
Old 07-11-2003, 02:35 PM   #13
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
All you need to do is change the settings on your router to forward higher port to your internal IP.You can still use port 22 on your server machine for SSH, that shouldn't matter. For example, you could forward from xxx.xxx.xxx.xxx:50 to 192.168.0.1:22 (well, as long as port 50 was unused). Which port you can use, obviously, depends on which ports your ISP is blocking..

Last edited by Nylex; 07-11-2003 at 02:38 PM.
 
Old 07-12-2003, 04:33 AM   #14
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 68
Quote:
Originally posted by Nylex
All you need to do is change the settings on your router to forward higher port to your internal IP.You can still use port 22 on your server machine for SSH, that shouldn't matter. For example, you could forward from xxx.xxx.xxx.xxx:50 to 192.168.0.1:22 (well, as long as port 50 was unused). Which port you can use, obviously, depends on which ports your ISP is blocking..
There was a post from someone the other day who could only forward the same port to another machine eg 80 - 80. It depends on your router. If you can't forward port 5000 say to 22 theh you can add this to the top of sshd_config and restart it:
Port 22
Port 5000

When connecting you will need to remember to change the port on the client. See the man page or help file for your client on how to do it.

As for X forwarding - it uses port 6000. You will need to forward that port too or do it over an ssh encrypted tunnel on port 22:
1) From the machine you are on (Xserver with display)
ssh -R 6000:127.0.0.1:6000 -l USER_ON_CLIENT -N ip.of.client.machine
2) Allow connections from the client - on the server run
xhost + ip.of.client.machine
3) Open another ssh session (leave the other as it is - no bash prompt "Ctrl + C" to end) to the client and set your display (this is the default - you only need to change it if you have set it different before)
export DISPLAY=127.0.0.1:0
4) Run your program
konqueror

One reason it may not have worked before (only just thoguth of this) is that some apps prefer a call like "konqueror -display=ip.of.x.server:0" rather than reading it from the DISPLAY variable.
 
Old 07-12-2003, 04:38 AM   #15
isme
LQ Newbie
 
Registered: Jul 2003
Posts: 12

Rep: Reputation: 0
if you not want to open your whole X server, you also might try ssh -X remote_host
or ssh -Xf remote_host <program_name>
 
  


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 from outside throough a router alagenchev Linux - Networking 5 01-20-2006 08:18 PM
ssh trhough a router from outside DropSig Linux - Networking 1 07-04-2005 04:07 PM
Got new router, can't ssh in now Chuk Linux - Networking 2 10-16-2004 01:52 AM
ssh and router, I need help. babyboss Linux - Networking 4 09-22-2004 11:40 AM
SSH , RH 9 and router weird_guy Linux - Networking 6 07-13-2003 09:17 PM

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

All times are GMT -5. The time now is 09:00 AM.

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