0

I'm having issues ssh'ing home server from outside the LAN.

As far as I know, the issue may have cropped up when I installed VPN client on my router. But it may have been like this before. I'm unsure.

I had it setup to verify through key-pairs, so that I didn't have to always type in the password, but would also allow password access so that my partner could access the server.

login though LAN (username obfuscated)

$ ssh -v [email protected]
OpenSSH_5.9p1, OpenSSL 0.9.8x 10 May 2012
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to 192.168.1.1 [192.168.1.1] port 22.
debug1: Connection established.
debug1: identity file /Users/user/.ssh/id_rsa type 1
debug1: identity file /Users/user/.ssh/id_rsa-cert type -1
debug1: identity file /Users/user/.ssh/id_dsa type -1
debug1: identity file /Users/user/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: DSA 3e:6e:35:b3:05:14:39:bb:6f:a6:29:4e:a3:a8:59:81
debug1: Host '192.168.1.1' is known and matches the DSA host key.
debug1: Found key in /Users/user/.ssh/known_hosts:1
debug1: ssh_dss_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/user/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
Authenticated to 192.168.1.1 ([192.168.1.1]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_AU.UTF-8
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.2.0-49-generic x86_64)user

login through domain name (the domain name, username and ip address are obfuscated, but correct). Note the use of -p flag... this has to be done, because all traffic is sent through a VPN, on the router. The VPN service allow port forwarding of specified ports:

$ssh -v -p nnnnn [email protected]
OpenSSH_6.2p2, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to my.domain.com [xxx.xxx.xxx.xxx] port nnnnn.
debug1: Connection established.
debug1: identity file /usr/home/user/.ssh/id_rsa type 1
debug1: identity file /usr/home/user/.ssh/id_rsa-cert type -1
debug1: identity file /usr/home/user/.ssh/id_dsa type -1
debug1: identity file /usr/home/user/.ssh/id_dsa-cert type -1
debug1: identity file /usr/home/user/.ssh/id_ecdsa type -1
debug1: identity file /usr/home/user/.ssh/id_ecdsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version dropbear_2013.58
debug1: no match: dropbear_2013.58
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Server host key: RSA 46:4c:2f:53:72:75:da:d8:e4:fc:d4:55:86:90:6a:3c
debug1: checking without port identifier
The authenticity of host '[my.domain.com]:nnnnn ([xxx.xxx.xxx.xxx]:nnnnn)' can't be established.
RSA key fingerprint is 46:4c:2f:53:72:75:da:d8:e4:fc:d4:55:86:90:6a:3c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[my.domain.com]:nnnnn,[xxx.xxx.xxx.xxx]:nnnnn' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /usr/home/user/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /usr/home/user/.ssh/id_dsa
debug1: Trying private key: /usr/home/user/.ssh/id_ecdsa
debug1: Next authentication method: password
[email protected]'s password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
[email protected]'s password:

Here is my sshd_config file:

# 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
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

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

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
#PermitRootLogin yes
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
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
Subsystem sftp internal-sftp

# 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

Does anyone know what's going on here?

I can connect to the domain through port 80 (the dev website displays fine), but obviously cannot use git or sftp from outside the lan, because they use port 22.

Thanks.

2
  • I worked it out - the VPN on the router is breaking it. Of course it was still working on the LAN, because the nat would just resolve that for me. As soon as I tested ssh from a different locations, it could not resolve the location of the domain name. Sorry for wasting anyone's time. Jul 27, 2013 at 4:34
  • actually, that doesn't fully resolve it. i set up port forwarding through the VPN service, and routed that to port 22, so now i can do ssh -v -p nnnnn [email protected] and i still get the same stuff. i'll update the original post Jul 27, 2013 at 4:48

1 Answer 1

0

I worked it out - the VPN on the router is breaking it. Of course it was still working on the LAN, because the nat would just resolve that for me.

As soon as I tested ssh from a different locations, i got:

ssh -v [email protected]
OpenSSH_6.2p2, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to my.domain.name [xx.xx.xx.xx] port 22.
debug1: connect to address xx.xx.xx.xx port 22: Connection timed out
ssh: connect to host my.domain.name port 22: Connection timed out

So it could not resolve the domain name, nor port.

What I had to do:

  1. Visit AirVPN site, get a random port forward set up, and set the exit port of that to 22.
  2. Do not port forward on the router.
  3. Set up iptables for the NAT to route port 22 to the puter:

    iptables -I FORWARD -i tun11 -p udp -d xx.xx.xx.xx --dport 22 -j ACCEPT

    iptables -I FORWARD -i tun11 -p tcp -d xx.xx.xx.xx --dport 22 -j ACCEPT

    iptables -t nat -I PREROUTING -i tun11 -p tcp --dport 22 -j DNAT --to-destination xx.xx.xx.xx

    iptables -t nat -I PREROUTING -i tun11 -p udp --dport 22 -j DNAT --to-destination xx.xx.xx.xx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.