How-to guides
Short, task-oriented pages. Each one starts with when to use it, shows focused examples, and ends with the pitfalls and links to
the in-depth guides. The examples assume a connected SshClient named client and a CancellationToken named
cancellationToken; Getting started shows how to get the client.
Every example on these pages is compiled with the library in CI, so it matches the current API.
Commands and shells
| Guide | Use it to |
|---|---|
| Run a command | Run a command and read its stdout, stderr and exit status. |
| Stream large output | Process output as it arrives, feed input, and handle output that does not fit in memory. |
| Interactive shells and SshExpect | Drive a shell or a device CLI with a terminal; wait for prompts and answer them. |
Files
| Guide | Use it to |
|---|---|
| Transfer files with SFTP | Upload, download, resume, copy directories, and work with remote files in place. |
| Transfer files with SCP | Copy files where the server has no SFTP. |
| IFileSystem and IFileProvider | Use remote files through System.IO.Abstractions or Microsoft.Extensions.FileProviders. |
Networking
| Guide | Use it to |
|---|---|
| Port forwarding and tunnels | Reach services behind the server (ssh -L, -R, -D), or give the server a way back. |
| Jump hosts (ProxyJump) | Reach hosts through one or more bastions. |
Configuration and trust
| Guide | Use it to |
|---|---|
| Use ssh_config and known_hosts | Connect by alias, ship your own configuration, read known_hosts. |
| Verify host keys | Choose a host key policy: known_hosts, pinning, certificates, or your own source of truth. |
Authentication
| Guide | Use it to |
|---|---|
| Keys and the SSH agent | Log in with key files, the agent, generated keys, or keys in a TPM, HSM or KMS. |
| Certificates | Log in with OpenSSH user certificates. |
| Kerberos | Log in with a Kerberos ticket (Active Directory). |
Reliability
| Guide | Use it to |
|---|---|
| Keep-alive and reconnecting | Notice dead connections and open new ones. |
| Cancellation and timeouts | Bound how long connecting and commands may take. |
| Logging and diagnostics | See what a connection does: logs, traces, metrics, negotiated algorithms. |
Applications
| Guide | Use it to |
|---|---|
| ASP.NET Core and dependency injection | Register SSH endpoints, share a connection, add a health check. |
| Unit-test code that uses SshSharp | Test your logic without a server. |
| Native AOT | Publish a trimmed, ahead-of-time compiled application. |
| FIPS mode | Use only FIPS-approved algorithms. |
| Migrate from SSH.NET | Map SSH.NET code to SshSharp. |