Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Unable to connect to a server using 2024.2.0: Key exchange negotiation failed

Đang mở
#1,617 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
csharp, fsharp
Lĩnh vực
backend, networking, security

Hướng nghiên cứu

Bắt đầu với các điểm vào KeyExchangeECCurve25519 và Session được hiển thị trong exception, so sánh hành vi giữa SSH.NET 2024.1.0 và 2024.2.0. Tái hiện lỗi bằng /home/vmadmin/temp/print-sftp-files.fsx với khóa ed25519 được mã hóa base64; hoàn tất khi sample kết nối và liệt kê thư mục được yêu cầu như đã làm với 2024.1.0.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Unable to connect to a server when using SSH.NET 2024.2.0 and base64-encoded ed25519 private key. Version 2024.1.0 works fine.

This is the exception I'm getting:

Renci.SshNet.Common.SshConnectionException: Key exchange negotiation failed.
   at Renci.SshNet.Security.KeyExchange.Finish()
   at Renci.SshNet.Security.KeyExchangeECCurve25519.Finish()
   at Renci.SshNet.Security.KeyExchangeECCurve25519.Session_KeyExchangeEcdhReplyMessageReceived(Object sender, MessageEventArgs`1 e)
   at Renci.SshNet.Session.OnKeyExchangeEcdhReplyMessageReceived(KeyExchangeEcdhReplyMessage message)
   at Renci.SshNet.Messages.Transport.KeyExchangeEcdhReplyMessage.Process(Session session)
   at Renci.SshNet.Session.MessageListener()
--- End of stack trace from previous location ---
   at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout)
   at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle)
   at Renci.SshNet.Session.Connect()
   at Renci.SshNet.BaseClient.CreateAndConnectSession()
   at Renci.SshNet.BaseClient.Connect()
   at FSI_0002.main(String host, String user, String dir) in /home/vmadmin/temp/print-sftp-files.fsx:line 22
   at <StartupCode$FSI_0002>.$FSI_0002.main@() in /home/vmadmin/temp/print-sftp-files.fsx:line 30
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Stopped due to error

Here's my code:

#r "nuget: SSH.NET, 2024.2.0"

open Renci.SshNet
open System
open System.IO

let getAuthMethod (user : string) : AuthenticationMethod =
    let key = Environment.GetEnvironmentVariable "SSH_KEY"
    let pwd = Environment.GetEnvironmentVariable "SSH_PWD"

    if not (String.IsNullOrEmpty key) then
        new PrivateKeyAuthenticationMethod(user, new PrivateKeyFile(new MemoryStream(Convert.FromBase64String key)))
    else if not (String.IsNullOrEmpty pwd) then
        new PasswordAuthenticationMethod(user, pwd)
    else
        failwith "Environment variable SSH_PWD or SSH_KEY must be defined"

let main host user (dir: string) =
    let auth = getAuthMethod user
    use client = new SftpClient(new ConnectionInfo(host, user, auth))

    client.Connect()

    let res = client.ListDirectory dir

    for item in res do
        printfn "%s" item.FullName

match fsi.CommandLineArgs |> List.ofArray with
| [ _; host; user; dir ] -> main host user dir
| _ -> printfn "Usage: dotnet fsi %s <host> <user> <dir>" fsi.CommandLineArgs.[0]
Ngôn ngữ chính
C#
Star
4.4k
Fork
990
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của sshnet/SSH.NET

Tất cả issue của sshnet/SSH.NET

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.