SSH-Verbindung mit IPv6-Adresse

Home PDF Audio

Ich versuche, über IPv6 eine Verbindung zu einem Rechner in der Hetzner Cloud herzustellen. ssh 2a01:4f8:c17:2000::/64 funktioniert nicht, aber ssh root@2a01:4f8:c17:2000::1 schon.

Die IPv6-Adresse wurde aus der Hetzner Cloud Konsole kopiert.

Die Datei ~/.ssh/config kann so konfiguriert werden, dass unterschiedliche Proxy-Regeln für IPv4- und IPv6-Adressen angewendet werden. Diese Einrichtung erlaubt es, einen Proxy-Befehl für IPv4-Adressen anzugeben, während IPv6-Adressen anders behandelt werden.

Host 192.168.1.*
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa 
Host *.*.*.*
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa
    ProxyCommand corkscrew localhost 7890 %h %p
Host *
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa   

Bei der Ausführung von ssh root@192.168.1.3 zeigt die Ausgabe, dass der SSH-Client Konfigurationsoptionen aus der Datei ~/.ssh/config anwendet:

debug1: Reading configuration data /Users/lzwjava/.ssh/config
debug1: /Users/lzwjava/.ssh/config line 1: Applying options for 192.168.1.*
debug1: /Users/lzwjava/.ssh/config line 5: Applying options for *.*.*.*
debug2: add_identity_file: ignoring duplicate key ~/.ssh/id_rsa
debug1: /Users/lzwjava/.ssh/config line 10: Applying options for *
debug2: add_identity_file: ignoring duplicate key ~/.ssh/id_rsa
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug2: resolve_canonicalize: hostname 192.168.1.3 is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/lzwjava/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/lzwjava/.ssh/known_hosts2'
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug3: channel_clear_timeouts: clearing
debug1: Executing proxy command: exec corkscrew localhost 7890 192.168.1.3 22

Die SSH-Verbindungsgeschwindigkeit war merklich langsam, daher bin ich zu folgender einfacheren Konfiguration zurückgekehrt:

Host 192.168.1.*
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa 
Host *
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa  
    ProxyCommand corkscrew localhost 7890 %h %p 

Das Problem tritt auf, wenn IPv6-Adressen mit der Direktive ProxyCommand corkscrew localhost 7890 %h %p verwendet werden, da dieser Proxy-Befehl IPv6-Adressen möglicherweise nicht korrekt verarbeitet.

Die obige Konfiguration funktioniert immer noch nicht. Die folgende jedoch schon.

Host 192.168.1.*
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa 
Host !192.*.*.*
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa  
    ProxyCommand corkscrew localhost 7890 %h %p 
Host *
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa  

Back 2025.02.22 Donate