LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-07-2010, 08:30 AM   #1
clement172000
LQ Newbie
 
Registered: Dec 2010
Posts: 4

Rep: Reputation: 0
cannot connect via ssh from outside the network


Hi all,
I cannot connect to my server via ssh from outside my office network. Ssh from inside the network poses no problem. From outside the network, I can ping the server so I assume that there is no problem with the IP address. I am quite new to linux networking so pls forgive me if this is a stupid question. Is there any changes I need to make in the sshd_config file? Any comments will be appreciated.

Cheers,
Clement
 
Old 12-07-2010, 08:51 AM   #2
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
Ping works with ICMP messaging and is independent of the ports, but it is a good indication that you are resolving the host and that there is a base connection to it. Chances are that the port is blocked by a firewall. Since you can connect inside of your office, you know that the server is listening. If you are the system admin, then open port 22, or another port for use with SSH. If you are not the admin, then you will need to talk to them about opening the port. Beware that this poses security risks and if you open this port that you WILL get numerous attempts to brute force entry into your system, so be sure to properly secure it.
 
Old 12-07-2010, 07:31 PM   #3
clement172000
LQ Newbie
 
Registered: Dec 2010
Posts: 4

Original Poster
Rep: Reputation: 0
thanks noway2.

I have checked my server's ports using nmap localhost and here are the results:
21/tcp open ftp
22/tcp open ssh
25/tcp open smtp
111/tcp open rpcbind
113/tcp open auth
512/tcp open exec
513/tcp open login
514/tcp open shell
873/tcp open rsync
32774/tcp open sometimes-rpc11

So I think that port 22 is open.

My server's ssh_config is as follow:
# Host *
# ForwardAgent no
# ForwardX11 no
# RhostsRSAAuthentication no
# RSAAuthentication yes
# PasswordAuthentication yes
# HostbasedAuthentication no
# BatchMode no
# CheckHostIP yes
# AddressFamily any
# ConnectTimeout 0
# StrictHostKeyChecking ask
# IdentityFile ~/.ssh/identity
# IdentityFile ~/.ssh/id_rsa
# IdentityFile ~/.ssh/id_dsa
# Port 22
# Protocol 2,1
etc...

Cheers,
Clement

Last edited by clement172000; 12-07-2010 at 07:35 PM.
 
Old 12-07-2010, 08:00 PM   #4
clement172000
LQ Newbie
 
Registered: Dec 2010
Posts: 4

Original Poster
Rep: Reputation: 0
I forgot to put more info. The server is running CentOS 4 and has two IP addresses. One is local inside my office's router (192.168-based) and another one is global (abc.d.efg.OOO. The error I got when trying to access from outside the network to the global ip address is "connection timed out". No problem accessing the local and global IP addresses from inside the office network.

Here are some information on my network:
Laptop: in the office, it is router-connected (192.168-based). When I checked my laptop's IP address using whatismyipaddress.com, it reports abc.d.efg.xxx
Server global IP address: abc.d.efg.OOO.

So I guess the server only accepts connections from the same IP family. Any advice on how to change this? Thanks.

Last edited by clement172000; 12-07-2010 at 08:23 PM.
 
Old 12-07-2010, 10:16 PM   #5
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
You should be able to have two interfaces, one public, one private, like you do. This may be a dumb question, but did you set the port forward on your router to forward port 22 traffic from your public IP to your server's LAN IP? In other words, all inbound connections on port 22 will be sent to your SSH server?
 
Old 12-07-2010, 10:47 PM   #6
clement172000
LQ Newbie
 
Registered: Dec 2010
Posts: 4

Original Poster
Rep: Reputation: 0
noway2, thanks for your comments. I am sorry that I did not explain in detailed enough. What I meant with having two IP addresses is that the server has two ethernet cards, both are functional. Here is the result of ifconfig:
eth0 Link encap:Ethernet HWaddr
inet addr: xxx.x.xxx.9 Bcast:xxx.x.xxx.255 Mask:255.255.255.0
inet6 addr: fe80::222:19ff:fe25:5239/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1163911 errors:0 dropped:0 overruns:0 frame:0
TX packets:170367 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:395995668 (377.6 MiB) TX bytes:56359050 (53.7 MiB)
Interrupt:169 Memory:e6000000-e6012100

eth1 Link encap:Ethernet HWaddr 00:22:19:25:52:3B
inet addr:192.168.0.167 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::222:19ff:fe25:523b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2146613 errors:0 dropped:0 overruns:0 frame:0
TX packets:584646 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1585497051 (1.4 GiB) TX bytes:113112340 (107.8 MiB)
Interrupt:177 Memory:e8000000-e8012100

From inside the office network, I can ssh to both 192.168.0.167 and xxx.x.xxx.9.

when I checked my server's IP address using whatismyipaddress.com, it gave the same value as it is (xxx.x.xxx.9), no gateway to the internet.
 
Old 12-08-2010, 12:03 AM   #7
dreamer.redeemer
LQ Newbie
 
Registered: Jan 2008
Distribution: Ubuntu, Suse 11, etc...
Posts: 20

Rep: Reputation: 0
It's not clear if the rest of the network is configured correctly, and with two interfaces ping doesn't necessarily rule this out. If the ssh daemon is running and the configured port open on localhost but the server isn't logging the SSH attempts from WAN, something is dropping them before they get there.
 
Old 12-08-2010, 05:31 AM   #8
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
In your ssh configuration, do you have anything that could be binding SSH to only your 192.168.0.167, i.e. it is not listening on your xxx.x.xxx.9 port. Use a command like netstat -ane to see if it is listening on that interface. You could also run nmap on your xxx.x.xxx.9 address.

If you have a listen address directive, you may want to comment it out, even if it is set to 0:0:0:0. I have a similar setup with my servers with one NIC that is private (192.168.0.x) and one that is on my public IP block. Both of them will accept connections and show up as being bound to 0:0:0:0:22 in netstat.

Lastly, double check that you don't have Iptables blocking your application.
 
Old 12-08-2010, 09:23 AM   #9
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Another place to look at are /etc/hosts.allow and /etc/hosts.deny which might block access from certain addresses. Any entry for sshd there?
 
  


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
Able to connect via SSH but not able to connect via web port 80 Orange Sunshine Linux - Server 9 04-03-2010 08:11 PM
ssh issues - can't connect from external network, internal okay dragos19 Linux - Server 5 06-10-2008 10:13 PM
Can't connect to ssh from external network? BlueSpam Linux - Networking 6 02-02-2007 12:55 AM
ssh + pop3 with kmail: Could not connect to host localhost, but ok without ssh Emmanuel_uk Linux - Networking 0 07-20-2006 05:56 PM
ssh wont connect outside of local network clintonkerr Linux - Software 9 09-20-2005 08:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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