LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 10-09-2014, 11:21 AM   #1
pulper
LQ Newbie
 
Registered: Jul 2006
Posts: 18

Rep: Reputation: 0
SSH not connecting over the internet but can connect on the local internet


Hello – I am trying to connect via SSH to a computer over the internet.

I am currently able to do this through my internal network, but all attempts to do this over the internet have failed. Right now the two computers (client and server) are at the same location for testing purposes.

I have forwarded the port on the router. This looks as follows:
Rule Name: SSH
Protocol: TCP
Source Port: 22
Destination IP: 192.168.0.5
Destination Port: 22

The server is running the latest version of Lubuntu (32 bit).
On the client side, I have tried both Windows 8.1 (using Putty) and Ubuntu 64 bit (through USB).

When I login over the internal network, it works both with Ubuntu and Windows (Putty).

When I login over the internet, I immediately get “connection refused” using both Ubuntu and Windows (Putty). If the server name is myserver, the public IP of the server is 99.99.99.99 (obviously not right but for example) and the user name on the server is username, then on the Ubuntu client I do the following command:
ssh username@99.99.99.99
I've also tried:
ssh -l username 99.99.99.99
ssh username@99.99.99.99:22

On Putty/Windows, I do the above however without ssh or ssh -l

When I have checked the firewall using “sudo ufw status” on both Lubuntu and Ubuntu, I get “Status: inactive”.

Windows Firewall/AV I have turned off during testing. Same results.

I have verified using “shields up” that port 22 is open at my public IP address

on the server, nmap -p ipaddress gives:
Port: 22/tcp
State: open
Service: ssh

on the server, ps -A | grep sshd gives:
877 ? 00:00:00 sshd
1667 ? 00:00:00 sshd
1773 ? 00:00:00 sshd


Any clues as to what I have missed? Thank you.

The /etc/ssh/sshd_config file on the server reads as follows:

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
 
Old 10-09-2014, 12:08 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Your modem/router might not allow loopback connections (connecting to your own public IP from within your network). What happens if you try to log in from outside your network? It should be enough to ssh somewhere (like home) and then try to ssh back.
 
Old 10-09-2014, 02:56 PM   #3
pulper
LQ Newbie
 
Registered: Jul 2006
Posts: 18

Original Poster
Rep: Reputation: 0
That works now! Thanks a lot. Is there anyway, however, to modify the router's software to allow loopback connections (so I can test it easily)? I know each router is different, but if you have any suggestions as to what to look for in the software (if anything), that would be appreciated. Thank you again.
 
Old 10-09-2014, 03:08 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Unfortunately I've only experienced this once before (with a Comcast Business modem/router), and I never found a way around it. I ended up setting up a local DNS server on the network with an entry for the box, so whenever somebody on the local network types in the URL they get pushed straight to the box's LAN IP instead of trying to access it through its public IP.
 
Old 10-09-2014, 03:28 PM   #5
pulper
LQ Newbie
 
Registered: Jul 2006
Posts: 18

Original Poster
Rep: Reputation: 0
well, that's too bad but at least i have the reason that it wasn't working figured out. Thanks again for that.
 
  


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
newbie - connecting to internet with ssh, is there a better way? brandonweinberg Linux - Networking 6 01-14-2011 12:14 AM
Can connect to internet but not local network Plano Linux - Networking 3 05-03-2010 10:50 AM
3 nics, connect to internet, share to local net, and connect to local net. Not workin linux-i386 Linux - Networking 2 09-15-2009 09:13 PM
can connect to internet but not local windows pc jtodd Linux - Networking 6 05-20-2006 02:52 PM
help: ubuntu as a server connecting local network to internet ctdarksilver Linux - Networking 2 10-26-2005 09:17 PM

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

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