Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to negotiate <host> port 22, no matching key exchange / host key algorithm found. #406

Closed
Shiraj0205 opened this issue Mar 22, 2018 · 14 comments

Comments

@Shiraj0205
Copy link

Getting an error on sshClient.Connect().
Does library supports ssh-dss host key algorithm? Though it supports diffie-hellman-group1-sha1, why i am getting no matching key exchange method found error?

Unable to negotiate with XXXXXX port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
Unable to negotiate with XXXXXX port 22: no matching host key type found. Their offer: ssh-dss

@SaddamBInSyed
Copy link

did you get an answer for this?

Please help

@darkoperator
Copy link

darkoperator commented Apr 21, 2019 via email

@SaddamBInSyed
Copy link

many thanks for your reply.

error message at the server end,

Unable to negotiate with 172.28.102.92 port 53513: no matching host key type found. Their offer: ssh-rsa,ssh-dss [preauth]

please advise,

i am using below code,

var connectionInfo = new ConnectionInfo(host, username, new PasswordAuthenticationMethod(username, password));
connectionInfo.Timeout = new TimeSpan(0, 0, 20); // connection Timeout

using (SftpClient sftpClient = new SftpClient(connectionInfo))
{
sftpClient.HostKeyReceived += SftpClient_HostKeyReceived;
sftpClient.ErrorOccurred += SftpClient_ErrorOccurred;

                Console.WriteLine("Connecting to server");
                sftpClient.Connect();
                Console.WriteLine("connected");
                //using (FileStream fs = new FileStream("filePath", FileMode.Open))
                //{
                //    sftpClient.BufferSize = 1024;
                //    sftpClient.UploadFile(fs, Path.GetFileName("filePath"));
                //}
                sftpClient.Dispose();
            }

@darkoperator
Copy link

darkoperator commented Apr 21, 2019 via email

@SaddamBInSyed
Copy link

sorry for asking, where can i see that information ( key algorithim)?

@SaddamBInSyed
Copy link

When I try to connect with the server then I am getting the below error.

please help.

Renci.SshNet.Common.SshConnectionException: An existing connection was forcibly closed by the remote host ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at Renci.SshNet.Abstractions.SocketAbstraction.Read(Socket socket, Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
at Renci.SshNet.Session.TrySocketRead(Byte[] buffer, Int32 offset, Int32 length)
at Renci.SshNet.Session.ReceiveMessage()
at Renci.SshNet.Session.MessageListener()
--- End of inner exception stack trace ---
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.Connect()
at FtpEngine.ftp.Upload.UploadFilestoSFTPUsingSSH(tb_ftpconfig _configs)

@darkoperator
Copy link

darkoperator commented Apr 21, 2019 via email

@darkoperator
Copy link

darkoperator commented Apr 21, 2019 via email

@SaddamBInSyed
Copy link

ssh-dss - ssh-rsa

@SaddamBInSyed
Copy link

When run the below command i can am getting the following

PS C:\Users\duak5031> ssh -Q key
ssh-ed25519
[email protected]
ssh-rsa
ssh-dss
ecdsa-sha2-nistp256
ecdsa-sha2-nistp384
ecdsa-sha2-nistp521
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

please advise

@SaddamBInSyed
Copy link

At least from the error my guess is that you will have to reconfigure the server to use a key with one of the supported algorithms by the library

Sent from my iPhone
On Apr 21, 2019, at 9:35 AM, SaddamBinSyed @.***> wrote: many thanks for your reply. error message at the server end, Unable to negotiate with 172.28.102.92 port 53513: no matching host key type found. Their offer: ssh-rsa,ssh-dss [preauth] please advise, i am using below code, var connectionInfo = new ConnectionInfo(host, username, new PasswordAuthenticationMethod(username, password)); connectionInfo.Timeout = new TimeSpan(0, 0, 20); // connection Timeout using (SftpClient sftpClient = new SftpClient(connectionInfo)) { sftpClient.HostKeyReceived += SftpClient_HostKeyReceived; sftpClient.ErrorOccurred += SftpClient_ErrorOccurred; Console.WriteLine("Connecting to server"); sftpClient.Connect(); Console.WriteLine("connected"); //using (FileStream fs = new FileStream("filePath", FileMode.Open)) //{ // sftpClient.BufferSize = 1024; // sftpClient.UploadFile(fs, Path.GetFileName("filePath")); //} sftpClient.Dispose(); } — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

So what I understood is, we need to add the library supported key algorithm in to SFTP server config files?
Is it so??

please help

@SaddamBInSyed
Copy link

I have added below config to the sshconfig file

HostKeyAlgorithms +ssh-rsa,ssh-dss
KexAlgorithms +diffie-hellman-group1-sha1

@drieseng
Copy link
Member

drieseng commented Apr 30, 2020

In the next beta, we'll add support for the following key exchange algorithms:

  • curve25519-sha256
  • curve25519-sha256@libssh.org
  • ecdh-sha2-nistp256
  • ecdh-sha2-nistp384
  • ecdh-sha2-nistp521
  • diffie-hellman-group14-sha256
  • diffie-hellman-group16-sha512

and we've added support for the following host key algorithms:

  • ssh-ed25519
  • ecdsa-sha2-nistp256
  • ecdsa-sha2-nistp384
  • ecdsa-sha2-nistp521

@drieseng drieseng added this to the 2020.0.0-beta1 milestone Apr 30, 2020
@drieseng
Copy link
Member

drieseng commented Jun 7, 2020

2020.0.0-beta1 is now available.

@drieseng drieseng closed this as completed Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants