Skip to content

System.Net.Sockets.SocketException: 'An existing connection was forcibly closed by the remote host.' #1002

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

Open
Bradenb25 opened this issue Sep 1, 2022 · 3 comments

Comments

@Bradenb25
Copy link

Bradenb25 commented Sep 1, 2022

I'm able to initially connect to the sftp server. However, after the initial file upload I try and reconnect to upload another file. This is when I get 'An existing connection was forcibly closed by the remote host.' The connection and upload process I'm using is very simple.

image

It seems like when I disconnect it's not fully disconnecting so when trying to reconnect it throws this exception.

@mittapalliseshu
Copy link

Did you get a fix for this? even I am facing the same issue now.

@duncan-bradley
Copy link

duncan-bradley commented Nov 1, 2022

Update:
You have to create a host key on AWS that matches the type of key you are using for the private key....by default, the host key type used in AWS is not supported by this library.

I am getting the same issue connection to an AWS hosted SFTP server using v2020.0.2. The extact error from the AWS logs is :
ERRORS KEX_FAILURE Message="no matching host key type found" Kex=ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,ssh-dss SourceIP=...
I am using a ssh-rsa keyfile to authenticate, but this error suggests that AWS is not liking the host keyfile algorithm that is being sent. I tried to interrogate the type on the connectionInfo class using connectionInfo.CurrentHostKeyAlgorithm, but this returns null as it is not connected at that point.
Any ideas any one?

@revealer409
Copy link

Solution: In my case I was using SSH.NET library from some xyz vendor removed package from Nugget package manager and then installed SSH.NET by Renci fixed my issue.

issue background: due to some issue infra team has deleted FTP/*/Log directory from Server after that i was getting this issue
'An existing connection was forcibly closed by the remote host'

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