SSH funktioniert lokal, aber nicht über VPN

Stryke7

PCGHX-HWbot-Member (m/w)
Hi zusammen,

ich brauche mal eure Hilfe:

Ich betreibe ein Netzwerk, in welchem der Router gleichzeitig ein VPN-Server ist.
Dahinter laufen zwei Ubuntu Server, nennen wir sie mal US1 und US2.

Wenn ich lokal im Netzwerk bin, kann ich mich mit beiden per SSH verbinden.

Wenn ich allerdings über VPN im Netz bin, kann ich mich mit US1 verbinden, US2 gibt mir hingegen ein "Connection Refused".
Ich kann das Problem umgehen indem ich eine shell zu US1 aufmache und mich von da aus mit US2 verbinde.

Aber warum lehnt US2 meine Verbindung ab, wenn ich VPN nutze?
Liegt das Problem an US2, oder am Router/VPN-Server?

Danke für eure Ideen!
 
Kann an vielen Faktoren liegen:
- Adresskonflikt (IP Adressen doppelt!?) Feste IPs vergeben oder per DHCP?
- Firewall auf US2 aktiv? -> temporär deaktivieren
- Zugangsprofil im Router für US2 eingeschränkt?!
- Logs auf US2 prüfen
 
versuch mal im ssh verbose mode mehr informationen zu holen:

Bash:
ssh -vv username@host

wie machst du das port forwarding von router/vpn zu us1/us2?
hast du verschiedene ssh configurations für die beiden server?
lässt sich us2 zumindest pingen oder sind vielleicht noch andere ports offen die man versuchen kann? (telnet)
versuche vielleicht auch ein traceroute auf beiden hosts und sie nach wo traceroute bei us2 hängen bleibt
 
Zuletzt bearbeitet:
Kann an vielen Faktoren liegen:
1 Adresskonflikt (IP Adressen doppelt!?) Feste IPs vergeben oder per DHCP?
2 Firewall auf US2 aktiv? -> temporär deaktivieren
3 Zugangsprofil im Router für US2 eingeschränkt?!
4 Logs auf US2 prüfen
1) Der Router sowie die beiden Server haben feste Adressen. Der Rechner bekommt eine feste Adresse aus einem Pool von festen Adressen, die für VPN Clients reserviert sind.
Die Details verstehe ich auch nur so halb, unser Router der das alles konfiguriert hat eine sehr unverständliche Konfigurationsoberfläche ...

2) ufw ist abgeschaltet. iptables --list sagt, es hat alles offen (also accept all protocols, any source, any destination) für Input und Forward, für Output ist kein Eintrag da

3) Ich bin nicht sicher ob der so ein Feature hat ... Es handelt sich um einen Ubiquiti EdgeRouterX

4) tcpdump sagt einfach gar nichts zu einem versuchten Verbindungsaufbau. Wie könnte ich das anders testen?


versuch mal im ssh verbose mode mehr informationen zu holen:

Bash:
ssh -vv username@host

wie machst du das port forwarding von router/vpn zu us1/us2?
hast du verschiedene ssh configurations für die beiden server?
lässt sich us2 zumindest pingen oder sind vielleicht noch andere ports offen die man versuchen kann? (telnet)
versuche vielleicht auch ein traceroute auf beiden hosts und sie nach wo traceroute bei us2 hängen bleibt

ssh -vv sagt mir leider nicht mehr zu dem Problem :(

Die Ports der Server sind in der Router-Firewall freigegeben.

Ping zu US2 funktioniert problemlos. Ansonsten hat der nicht viel offen, glaube ich ... Ich könnte man versuchen einen anderen Dienst aufzumachen.

Traceroute löst den Pfad fehlerfrei auf.
 
ssh -vv sagt mir leider nicht mehr zu dem Problem :(

Ok aber was sagt der output?

ssh service läuft auch auf port 22 oder ein anderer?

funktioniert
Bash:
telnet <host> 22
?

Die Ports der Server sind in der Router-Firewall freigegeben.

Ping zu US2 funktioniert problemlos. Ansonsten hat der nicht viel offen, glaube ich ... Ich könnte man versuchen einen anderen Dienst aufzumachen.

Traceroute löst den Pfad fehlerfrei auf.

Okay also du kannst us2 offenbar erreichen (vom VPN), ich bekomme das gefühl deine ssh config möglicherweise nicht ganz richtig konfiguriert ist. Hast du irgendwas in /etc/ssh/ssh_config.d/ oder /etc/ssh/ssh_config geändert/erstellt?
 
Zuletzt bearbeitet:
Der SSH Port ist auf 4440 verlegt worden.

Der (anonymisierte) Output von ssh -vv:
Bash:
{Nutzer}@{Computer}:~$ ssh -vv {DNS-Name} -p 4440
OpenSSH_8.3p1 Ubuntu-1, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /home/{Nutzer}/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolving "{DNS-Name}" port 4440
debug2: ssh_connect_direct
debug1: Connecting to {DNS-Name} [{IP Adresse}] port 4440.
debug1: connect to address {IP Adresse} port 4440: Connection refused
ssh: connect to host {DNS-Name} port 4440: Connection refused
Ich sehe da keine neuen Informationen drin.


Telnet sagt mir für Port 22 und 4440
Bash:
telnet: Unable to connect to remote host: Connection refused


Okay also du kannst us2 offenbar erreichen (vom VPN), ich bekomme das gefühl deine ssh config möglicherweise nicht ganz richtig konfiguriert ist. Hast du irgendwas in /etc/ssh/ssh_config.d/ oder /etc/ssh/ssh_config geändert/erstellt?
Meinst du etc/ssh/ssh_config auf dem Server? Das ist Installation des Betriebssystems unverändert. Die etc/ssh/sshd_config ebenfalls, bis auf den geänderten Port.
 
okay dann ist es für mich ziemlich klar dass irgendwas dazwischen traffic zu deinem zweiten host dropped, jetzt gilt es herauszufinden was

sicher dass die router firewall traffic zulässt?

genau die sshd config meine ich, kann ich die mal sehen nur zur sicherheit?
 
Zuletzt bearbeitet:
Code:
#    $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

Include {root}etc/ssh/sshd_config.d/*.conf

Port 4440
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile    .ssh/authorized_keys .ssh/authorized_keys2

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

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

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no

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

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

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no

# 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

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

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

# override default of no subsystems
Subsystem sftp    /usr/lib/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#    X11Forwarding no
#    AllowTcpForwarding no
#    PermitTTY no
#    ForceCommand cvs server
PasswordAuthentication yes


Das hier ist die sshd_config.

Der inkludierte sshd_config Unterordner ist leer, von da aus werden also keine weiteren Files eingebunden. (Den Pfad musste ich anpassen da das Forum keine Dateipfade in den Posts mag)

Ich schaue noch mal in die Firewall-Regeln des Routers, ob ich irgendwas übersehen habe, bzgl SSH des Servers oder VPN ...
 
Zurück