This project is read-only.

Troubleshooting SSH.NET

If you encounter problems using the library, use this page as a reference on how to try find the source of the problem.

Please ensure you are using the latest release of SSH.NET. If you are already using the latest release, then download and compile the latest Source Code. Don't forget to update your project(s) reference(s).

You may also find How to enhance debugging experience with SshNet useful.

Table of Contents

  1. Template for submitting an issue report
  2. How to narrow your problem down
    1. Frequently experienced SSH.NET exceptions
    2. System.Net.Socket exceptions
    3. .NET TraceSource and TraceListeners
  3. SSH server assisted troubleshooting
    1. Log files
    2. Debugging mode
      1. Debug level
      2. Foreground process
  4. Unsupported remote systems
    1. Watchguard Firewall

Template for submitting an issue report

Before you submit an issue report, please ensure you are using the latest release of SSH.NET. If you are already using the latest release, then download and compile the latest Source Code. Don't forget to update your project(s) reference(s).

Additionally, try to narrow down the problem by creating a very simple example that reproduces the problem you have. This is an important step, because it will eliminate most issues relating from other code that might influence the behavior of SSH.NET

Please use this template when submitting a new issue report. It will provide the necessary details for a more precise understanding of the problem you have.

Just copy everything between the 2 lines and paste them into the Create Issue Description textbox.

Remote Server Information

Remote SSH Server version:

Remote Operating System distribution name and architecture (x32/x64):

What kind of access do you have?:

Does Putty/WinSCP work?:

Local Machine Information

Operating System (for Windows, run winver.exe):

.NET Framework versions installed (See C:\WINDOWS\Microsoft.Net\Framework):

Project information

What is your Target Framework set to, and architecture (x32/x64)?: 

Is your project multi-threaded/complex?:

.NET Framework or Mono?:

Source Code

Sample Code:

Exceptions and Stack Trace/Call Stack:

File transfer related

Transfer over LAN or Internet?:

File size in Bytes:

Uploading or Downloading?

Does remote server have enough space to store the file?

Do you have access to the file being uploaded or downloaded?

How to narrow your problem down

By creating the simplest possible code that reproduce the problem you are having, it will be easier to debug and to pinpoint exactly where and why the problem is happening. So take some time to create code that can reproduce the problem.

Frequently experienced SSH.NET exceptions

"Key exchange negotiation failed"

The client and the server cannot find a common algoritm for exchanging keys.

To find out what kind of algoritms the server supports, you can put a breakpoint in the Start(Session, KeyExchangeInitMessage)-method in Security\KeyExchange.cs.

"No suitable authentication method found to complete authentication."

The server is expecting a password/key authentication, but the client is sending a key/password, or an authentication mechanism that is not commonly supported by both client and server.

System.Net.Socket exceptions

Sometimes the server doesn't know what to do, and it just closes the connection and you'll get either of these exceptions

  • An existing connection was forcibly closed by the remote host

If you get any of the following exception descriptions, it might be a problem on the computer you are running the program from, or the network you are on, and you should try your program on a different computer and network.

  • A blocking operation was interrupted by a call to WSACancelBlockingCall
  • Connection was lost
  • A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied

.NET TraceSource and TraceListeners

SSH.NET contains some tracing functionality, but at the time of writing, this is very limited.

The XML samples here should be put in the app.exe.config under configuration -> system.diagnostics-element.

The samples here are based on samples posted in Durgaprasad Gorti's WebLog at Using System.Net Tracing


The System.Net.Sockets namespace has some tracing options, this is how you enable it.

<?xml version="1.0" encoding="UTF-8" ?>
        <trace autoflush="true" />
                <source name="System.Net.Sockets" maxdatasize="1024">
                        <add name="MyTraceFile"/>
                <source name="System.Net" maxdatasize="1024">
                        <add name="MyTraceFile"/>


                <add name="System.Net" value="Verbose" />
                <add name="System.Net.Sockets" value="Info" />


SSH server assisted troubleshooting


Log files

Sample command for reading sshd related messages from /var/log/messages:

cat /var/log/messages | grep "$(date '+%b %_d')" | grep sshd

Debugging mode

You can configure your SSH server to run in debugging mode, this will cause more extensive logging depending on the debug level.

Before you make changes to configuration files, make sure you have a backup of the original.

Also remember that if you stop the SSH server you are disconnected from the remote host.

Debug level

This method will increase the debug output from the SSH server to the log file.

Open /etc/ssh/sshd_config and locate LogLevel, this is usually set to INFO. Change it to DEBUG1, DEBUG2 or DEBUG3 for maximum detail, but you should start with DEBUG1 and move upwards.

Foreground process

This method will cause the SSH server to run in the foreground and not run as a background process. This method should only be used if you have physical access to the machine.

Unsupported remote systems

In some cases there are systems that SSH.NET cannot be used with. Here is the ones that are known to not work

Last edited Sep 14, 2012 at 4:31 PM by Kenneth_aa, version 19


No comments yet.