LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-18-2006, 11:37 PM   #1
mixtr
Member
 
Registered: Jul 2004
Location: Ottawa
Distribution: Arch, OpenBSD
Posts: 123

Rep: Reputation: 17
How do connect to a machine behind a router with ssh


Just what the title says. I have a smoothwall box that serves as a router and so my machine address is 198.162.x.y. I would like to connect to my machine when I'm not at home. I have more than machine connected to the router and I can access them all from within the lan with ssh.

Also I would like to connect to another machine that is connected with a modem from sympatico that seems to act like a router because the machine's ip from ifconfig is 192.168.x.y.
 
Old 03-18-2006, 11:37 PM   #2
mixtr
Member
 
Registered: Jul 2004
Location: Ottawa
Distribution: Arch, OpenBSD
Posts: 123

Original Poster
Rep: Reputation: 17
oops, typo in the title...
 
Old 03-19-2006, 12:08 AM   #3
bluelightning
Member
 
Registered: Mar 2006
Location: Redmond, WA
Distribution: FC4, WinXP Pro
Posts: 37

Rep: Reputation: 15
I've never used smoothwall, but the general process is to go to the router config page and port forward 22 to the computer running ssh.

Here is what you should set the options to:
Source IP (if available), leave blank
Source Port (if available): 22
Dest IP: 192.168.x.y
Dest Port (or just port): 22

I've never used a modem in Linux, so I can't help you there.
 
Old 03-19-2006, 09:34 AM   #4
mixtr
Member
 
Registered: Jul 2004
Location: Ottawa
Distribution: Arch, OpenBSD
Posts: 123

Original Poster
Rep: Reputation: 17
Ok tanx, now I understand that part, but I'm still confused as to how do you write the ssh command. Is it something like ssh -p 22 [user]@[ip] and because I said to foward port 22 to address 192.168.x.y I will connect to my computer?
If so I would have to set one port for each computer connected to my router

And last how do you set a Speedstream modem?
 
Old 03-19-2006, 10:31 AM   #5
mrclisdue
Senior Member
 
Registered: Dec 2005
Distribution: Slackware
Posts: 1,134

Rep: Reputation: 277Reputation: 277Reputation: 277
the ssh syntax:

ssh <destination or host ip address> <port>

eg ssh 192.168.0.2 22

however, ssh assumes port 22, so:

ssh 192.168.0.2

will suffice.

there are many other options

man ssh

if you're attempting to connect from outside your lan, and you don't have a static internet ip address, then you'll need a dynamic address (see no-ip.com)

you'll have to forward different public ports from your router to each internal pc

eg: 192.168.0.2 public port 22, private port 22
192.168.0.3 public port 9002 private port 22
192.168.0.4 public port 9004 private port 22

hence, to connect externally to 192.168.0.3:

ssh yourdynamicaddress.com 9004

as far as the slipstream modem is concerned, i'd be interested as well, as i spent a bit of time a few months ago trying to discover it's admin page (it's obviously setup as a dhcp server, but simple admin access via 192.168.0.1 didn't seem to work). i'm thinking that there may be a software access solution in the slipstream setup package. It's not important to me now, but it's something i can file for later....


cheers,

Last edited by mrclisdue; 03-19-2006 at 10:33 AM.
 
Old 03-19-2006, 10:57 AM   #6
mixtr
Member
 
Registered: Jul 2004
Location: Ottawa
Distribution: Arch, OpenBSD
Posts: 123

Original Poster
Rep: Reputation: 17
I'm good with connecting to my machines from inside the lan, what I want is to connect to a specific machine on my lan from OUTSIDE the lan:

[me not at home] -> Internet -> Router -> [my box at home]
 
Old 03-19-2006, 11:48 PM   #7
bluelightning
Member
 
Registered: Mar 2006
Location: Redmond, WA
Distribution: FC4, WinXP Pro
Posts: 37

Rep: Reputation: 15
First find out your external IP address. The simplest way is to go to http://www.whatismyip.com (while going through your router). Ssh into your computer at that IP address on port 22 (it's assumed).

Let's say that your external IP is 24.16.118.150. Then you would do:
ssh 24.16.118.150

If everything is correctly configured, that command will work both inside your network and outside.
 
Old 03-20-2006, 05:01 AM   #8
mixtr
Member
 
Registered: Jul 2004
Location: Ottawa
Distribution: Arch, OpenBSD
Posts: 123

Original Poster
Rep: Reputation: 17
Won't that only connect me to the router or if I foward port 22 to my machine it will connect me to it?.
 
Old 03-20-2006, 05:43 AM   #9
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
Quote:
Originally Posted by mixtr
Won't that only connect me to the router or if I foward port 22 to my machine it will connect me to it?.
Not if port forwarding is set up correctly on the Smoothwall Box. Point a browser one one of the machines in your "Green Zone" (Trusted Zone) to https://SmoothwallBoxIP:441. Under the networking tab, select port forwarding. Forward connections on port 22 to the computer that you want to connect to. Click OK.

Now, connect to your smoothwall box using your external IP, (not 192.168.*.*). The connection will be forwarded to the internal computer, and you will actually be connecting to that computer, not the smoothwall box,

I hope this helps
--Ian
 
Old 03-20-2006, 03:54 PM   #10
mixtr
Member
 
Registered: Jul 2004
Location: Ottawa
Distribution: Arch, OpenBSD
Posts: 123

Original Poster
Rep: Reputation: 17
Thanks, that is really helpful!
Now can I do something like foward port 44444 to 192.168.0.XXX port 22 and forward port 44445 to 192.168.0.YYY port 22 so I can have access to 2 of my machine. Or am I just too paranoid to try to 'stealth' my port 22.
 
Old 03-20-2006, 06:24 PM   #11
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
May I suggest from a security point of view, that simply connecting to ssh using a non-standard port is not the whole solution. Find out the IP address of your work/school/wherever, and only allow connections from those addresses. For example, I can connect to my computer from uni, but nowhere else, to prevent hackers.

To do this, you will need to modify /etc/rc.d/rc.firewall.up
Code:
$IPT -A INPUT -p TCP -s XXX.XXX.XXX.XXX --destination-port 22 -j ACCEPT
Also, monitor your logs on the computer that you are connecting to for unauthorized access.

--Ian
 
  


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
want to ssh/ftp to home machine (Slack) from office through home router fincher69 Linux - Networking 2 09-21-2005 10:55 PM
ssh connection from a Windows machine to a Linux machine pistachio Linux - Networking 1 08-30-2005 10:45 AM
how to open a dilog on local machine when i do ssh to remote machine fahad26 Programming 3 05-03-2005 07:39 PM
Samba: can't connect to my local linux machine but can connect to windows. Royle Linux - Networking 3 01-18-2005 05:32 PM
unable to connect to my linux router from internet using ssh shkkhanhyd Linux - Security 3 03-31-2004 09:44 PM

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

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