Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Possible issue with IPv6 client connecting to an iPv4 host

未关闭
#1,639 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
csharp
领域
networking

调研方向

从最小的 C# 复现以及报告中提到的连接入口 SshClient.Connect 和 SftpClient 开始。在启用和禁用 IPv6 的情况下进行复现,将连接行为与终端 SSH 客户端进行比较,并确定是否定义了 IPv4-only 选项。当所需行为和配置界面已记录,或由经过验证的测试提供支持时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

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?

主要语言
C#
星标
4.4k
派生
993
平均合并
9 天 21 小时
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sshnet/SSH.NET 的其他 Issue

查看 sshnet/SSH.NET 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。