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 05-07-2008, 01:51 AM   #1
konqi
Member
 
Registered: Oct 2007
Distribution: Gentoo, Slackware
Posts: 162

Rep: Reputation: 16
ssh to computer in other network?


let's say:

my computer is at network 1
the other computer is by my friend at network 2

is it possible to ssh from my computer to the computer in network 2 (over the internet)?
 
Old 05-07-2008, 02:17 AM   #2
duryodhan
Senior Member
 
Registered: Oct 2006
Distribution: Slackware 12 Kernel 2.6.24 - probably upgraded by now
Posts: 1,054

Rep: Reputation: 46
do both of you have ipv4 addresses ? or are both of you behind a NAT (with an ip like 10.* or 192.* or 172.* etc.)

in the first case it is easily directly possible

in the other case it is a little involved ... I haven't done this myself but I think it would involve you setting up a port forward rule at the router .
 
Old 05-07-2008, 05:53 AM   #3
konqi
Member
 
Registered: Oct 2007
Distribution: Gentoo, Slackware
Posts: 162

Original Poster
Rep: Reputation: 16
if you mean the ip address of the computer itself (not the networks ip address) then i think we haven something like 192.* (but i'm not sure about my friend).
 
Old 05-07-2008, 06:40 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If you want to connect to your friends computer, you will need to know his internet IP address. If he is behind a NAT router, then port 22 needs to be forwarded to his computer. This is done in the computer setup. He needs to be running the sshd daemon and have port 22 open on the computers firewall. If you are the only person who would be logging in with ssh, I'd recommend the "AllowUsers <yourusername>" option. Your friend might consider changing the port number used for ssh as well.
Having port 22 open on the router, hackers will start banging on it trying different username/password combinations. You might consider using public key authentication instead of username/password authentication.
 
Old 05-08-2008, 01:52 AM   #5
konqi
Member
 
Registered: Oct 2007
Distribution: Gentoo, Slackware
Posts: 162

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by jschiwal View Post
Having port 22 open on the router, hackers will start banging on it trying different username/password combinations. You might consider using public key authentication instead of username/password authentication.
It is also possible to chose an other port isn't it?

But when the port is open, which options doe i have to give to the standard ssh command?
 
Old 05-08-2008, 02:10 AM   #6
tajamari
Member
 
Registered: Jul 2007
Distribution: Red Hat CentOS Ubuntu FreeBSD OpenSuSe
Posts: 252

Rep: Reputation: 32
Quote:
Originally Posted by konqi View Post
It is also possible to chose an other port isn't it?

But when the port is open, which options doe i have to give to the standard ssh command?
Yes it can be change, but I think the issue here is an SSH connection between two different segments. If both are on different NAT, the problem here is the route.
 
Old 05-08-2008, 02:13 AM   #7
tajamari
Member
 
Registered: Jul 2007
Distribution: Red Hat CentOS Ubuntu FreeBSD OpenSuSe
Posts: 252

Rep: Reputation: 32
Quote:
Originally Posted by konqi View Post
It is also possible to chose an other port isn't it?

But when the port is open, which options doe i have to give to the standard ssh command?
If you know the IP address of your friend, check first if you can ping the machine, then do a traceroute, if the trace is complete, then there's no problem on the ssh connection. check first the network.
 
Old 05-08-2008, 05:00 AM   #8
konqi
Member
 
Registered: Oct 2007
Distribution: Gentoo, Slackware
Posts: 162

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by tajamari View Post
Yes it can be change, but I think the issue here is an SSH connection between two different segments. If both are on different NAT, the problem here is the route.
There is no problem, i just don't know how to ssh to another computer in another network.


But to i just have to use the ip address of the network by my friend, but how can i reach a comoputer inside that network?
 
Old 05-08-2008, 05:14 AM   #9
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
ssh username@ip_address_of_your_friend


eg.

ssh fred@82.156.2.343

you'll be asked about your friend's password.

and you're in

As someone previously mentioned, your friend needs to be running sshd daemon, and if he's behind the router port22 has to be forwarded to his machine.

hth
 
Old 05-08-2008, 06:15 AM   #10
konqi
Member
 
Registered: Oct 2007
Distribution: Gentoo, Slackware
Posts: 162

Original Poster
Rep: Reputation: 16
So 82.156.2.343 is the ip address of the network, and not the computer inside the network.

i will give it a try when he has linux running (because he hasn't it right now).

But what about two computers with the same username on it in the same network?
 
Old 05-08-2008, 07:24 AM   #11
lsteacke
Member
 
Registered: Jul 2007
Distribution: Ubuntu
Posts: 99

Rep: Reputation: 16
No, I think the 82.156.2.343 address is the address of your friends computer. However if your friend has an ip address in the 192.168.*.* range, this is when you will use his router ip instead

Code:
ssh user@router_ip
Just make sure, like everyone has said, that port 22 is forwarded to his computer on the router.

As for usernames, he will have to make you an account on his box. So your username must exist in /etc/passwd
 
Old 05-08-2008, 08:15 AM   #12
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
well 82.156.2.343 is a WLAN address, the external IP that is assigned to you by your ISP. Even if your ISP doesn't provide a truly static IP, on cable broadbands it doesn't change very often. Mine hasn't changed in almost a year. You can check this IP using a lot of websites (just google "what's my ip" etc.) This has nothing to do with your internal LAN IP, which usually is 192.x.x.x. which is assigned to a particular computer. I've got my IP address something like 83.x.x.x. (this is assigned by your ISP) Then I configured each of my computers to have a static IP eg. 192.168.1.100, 192.168.1.106, etc. At the moment I'm not at home but I can access my running computer through ssh because I configured my router to forward port 22 to 192.168.1.103 (which is a computer that is running at the moment)
Similarly, my Network Attached Storage device which is also connected to my router can be accessible because it is kind of an ftp server. And we know that ftp traditionally uses port 21 so I forwarded port 21 to 192.168.1.109 (which is the LAN ip address of this network drive/server. So whenever a packet is send to my modem (at 83.x.x.x) is then passed to my router and here it depends, if the packet uses port 22 it is directed to 192.168.1.103 (a running computer) if the packet uses port 21 (ftp) it goes to my NAS.

Well, I'm not an expert but that's how I understand it and it works. Perhaps, some more experienced members may correct some points.

HTH
 
Old 05-08-2008, 08:30 AM   #13
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Also, if you want to run some programs requiring X,
you need to add:

Quote:
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
to /etc/sshd_config (on fedora, don't remember the location/name of the file on debian)

and the command will be

Quote:
ssh -X user@ip_address
It'll enable GUI programs (which in some cases might be useful)

Last edited by sycamorex; 05-08-2008 at 08:31 AM.
 
Old 05-08-2008, 03:19 PM   #14
seraphim172
Member
 
Registered: May 2008
Posts: 101

Rep: Reputation: 15
Just a footnote:

to access SSH on a different port use
ssh user@<the IP-number here> -p <the portnumber here>
 
Old 05-08-2008, 08:05 PM   #15
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Quote:
Originally Posted by seraphim172 View Post
Just a footnote:

to access SSH on a different port use
ssh user@<the IP-number here> -p <the portnumber here>
or alternatively you can type:
Code:
ssh user@ipnumber:port
hth

Last edited by sycamorex; 05-08-2008 at 08:07 PM.
 
  


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
How do I ssh to another computer on the same network? SentralOrigin Linux - Networking 8 01-13-2008 08:23 PM
How to setup computer to computer network between Mandriva and Mac? ssass21 Mandriva 3 01-18-2007 03:46 AM
Computer to Computer Wireless Network How To Sir Lunch-a-lot Linux - Wireless Networking 5 10-18-2006 08:56 PM
SSH - How can i alllow someone SSH to my network from Internet - please help me b:z Linux - Networking 4 04-05-2005 07:21 AM
One computer on a three computer network having problems knightofdogbert General 2 10-20-2003 12:56 PM

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

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