The disposal of an SshClient instance could end throwing an exception when the SSH Session gets disconnected by the remote host. A quick look into the code shows that even if the Dispose methods calls Disconnect internally and doesn't have exception handling (https://github.com/sshnet/SSH.NET/blob/develop/src/Renci.SshNet/BaseClient.cs#L339) , there is always a null check over the SshSession (https://github.com/sshnet/SSH.NET/blob/develop/src/Renci.SshNet/BaseClient.cs#L225-L246) to prevent any unwanted NullReferenceException. However, something is still going on when the session is remotely disconnected and the SshClient is tried to be disposed after that.