Possible issue with IPv6 client connecting to an iPv4 host

Abierto
#1,639 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
csharp
Área
networking

Línea de trabajo

Comienza con la reproducción mínima en C# y los puntos de entrada de conexión SshClient.Connect y SftpClient mencionados en el informe. Reproduce el comportamiento con IPv6 habilitado y deshabilitado, compara el comportamiento de la conexión con el cliente SSH de terminal y determina si está definida una opción IPv4-only. Se considera terminado cuando el comportamiento requerido y la superficie de configuración están documentados o respaldados por una prueba verificada.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

TL;DR; Connections only work if I disable IPv6 on local machine. Client may accept IPv6 connections, but I can only whitelist IPv4 addresses. Can I force SSH.NET to use IPv4 only?

Hey,
I started working on an old project again where an app would connect to a remote server to transfer some files. I could not connect to my remote test servers, connection would time out. I reduced the example right down to the following,

var sshClient = new SshClient(Host, Port, Username, Password);
sshClient.ErrorOccurred += (sender, e) =>
{
    Debugger.Break();
};
sshClient.HostKeyReceived += (sender, eventArgs) =>
{
    Debugger.Break();
};
sshClient.ServerIdentificationReceived += (sender, eventArgs) =>
{
    Debugger.Break();
};
sshClient.Connect();
Debugger.Break();

If I took the credentials I can manually SSH to the server without issues.

ssh User@Host -p PORT
< input password

I have the issue across both my macOS and Windows machines here. Wondering if remote servers had changed I asked friend to try and they have no issues at all.

Remote host makes me input an IP address to whitelist my client machine. It only accepts IPv4 addresses, I tried an IPv6 address but it rejected it. If I disable IPv6 (tested on Windows by disabling in control panel) my connections work right away. So I think what is happening here is the host accepts an IPv6 connection but with no way to whitelist it I can't connect. I assume because the host accepts the IPv6 connection it won't attempt to fallback to IPv4. But if this is the case I don't understand why Terminal connects fine. I tried verbose output with ssh but I couldn't see any IPv4/6 things happening.

If I can confirm host accepts IPv6 connections I'll request they allow adding IPv6 whitelists which should solve the problem (at least on this host)

Is it possible to force SshClient and SftpClient use IPv4 if even if IPv6 is available?

Lenguaje dominante
C#
Estrellas
4.4k
Forks
993
Merge medio
9 d 21 h
PR fusionados (30 d)
1

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de sshnet/SSH.NET

Todos los issues de sshnet/SSH.NET

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.