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 thelatest release, then download and compile the latestSource Code. Don't forget to update your project(s) reference(s).
Table of Contents
- How to narrow your problem down
- .NET TraceSource and TraceListeners
- SSH server assisted troubleshooting
- Log files
- Debugging mode
- Debug level
- Foreground process
- Template for submitting an issue report
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.
.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
System.Net.Sockets
The System.Net.Sockets namespace has some tracing options, this is how you enable it.
<?xmlversion="1.0"encoding="UTF-8"?><configuration><system.diagnostics><traceautoflush="true"/><sources><sourcename="System.Net.Sockets"maxdatasize="1024"><listeners><addname="MyTraceFile"/></listeners></source><sourcename="System.Net"maxdatasize="1024"><listeners><addname="MyTraceFile"/></listeners></source></sources><sharedListeners><addname="MyTraceFile"type="System.Diagnostics.TextWriterTraceListener"initializeData="SshNetTrace.log"/></sharedListeners><switches><addname="System.Net"value="Verbose"/><addname="System.Net.Sockets"value="Info"/></switches></system.diagnostics></configuration>
SSH server assisted troubleshooting
References
- Run sshd in debugging mode. (fixunix.com)
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 toINFO. 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.
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 thelatest release, then download and compile the latestSource 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 IssueDescription 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?