Skip to content

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

Open

Description

@Bradenb25

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.

Activity

  1. mittapalliseshu commented on Oct 12, 2022

    @mittapalliseshu

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

  2. duncan-bradley commented on Nov 1, 2022

    @duncan-bradley

    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?

  3. revealer409 commented on Nov 7, 2024

    @revealer409

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions