SFTPServerLib 1.0.2

dotnet add package SFTPServerLib --version 1.0.2
                    
NuGet\Install-Package SFTPServerLib -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SFTPServerLib" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SFTPServerLib" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="SFTPServerLib" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SFTPServerLib --version 1.0.2
                    
#r "nuget: SFTPServerLib, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SFTPServerLib@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SFTPServerLib&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=SFTPServerLib&version=1.0.2
                    
Install as a Cake Tool

SFTP Server

NuGet NuGet Downloads

A lightweight, enterprise-ready SFTP server built on .NET 8 using the FxSsh library. Compatible with popular SFTP clients like FileZilla, WinSCP, and OpenSSH.


Installation

dotnet add package SFTPServerLib

Features

  • Full SFTP v3 Support - Upload, download, rename, delete files and directories
  • User Management - Built-in user authentication with granular permissions
  • Audit Logging - Track all file operations for compliance and debugging
  • Connection Limits - Configure maximum concurrent connections
  • Cross-Platform - Runs on Windows, macOS, and Linux
  • Secure - RSA and ECDSA host key support with SHA-2 algorithms

Quick Start

Basic Usage

using SFTPServer.Services;

// Create configuration
var config = new SftpServerConfiguration
{
    ListenAddress = "127.0.0.1",
    Port = 22,
    EnableLogging = true,
    MaxConnections = 100
};

// Create user manager and configure users
var userManager = new UserManager();

// Add a user with full permissions
userManager.AddOrUpdateUser(new UserAccount("admin", "admin123", config.RootDirectory)
{
    IsEnabled = true,
    CanUpload = true,
    CanDownload = true,
    CanDelete = true,
    CanCreateDirectory = true
});

// Create and start SFTP server
var server = new SftpServer(config, userManager);
server.Start();

Console.WriteLine("Press Ctrl+C to stop the server...");
await Task.Delay(-1);

Configuration

SftpServerConfiguration Properties

Property Type Default Description
ListenAddress string? null IP address to listen on. null = all interfaces. Example: "127.0.0.1" for localhost only
Port int 22 SSH server port
RootDirectory string OS-specific* SFTP root directory where files are served from
MaxConnections int 100 Maximum concurrent connections allowed
EnableLogging bool true Enable debug logging to console
ConnectionTimeoutSeconds int 300 Connection timeout in seconds (0 = no timeout)
MaxUploadSizeMB int 0 Maximum upload file size in MB (0 = unlimited)
EnableAuditLog bool true Enable audit logging for file operations
AuditLogPath string OS-specific** Path to the audit log file
ServerBanner string "SSH-2.0-SFTP_1.0" Server banner message (must start with "SSH-2.0-")
RsaHostKey string Auto-generated RSA host key in PEM format
EcdsaP256HostKey string Auto-generated ECDSA P-256 host key in PEM format

* RootDirectory defaults:

  • All platforms: ~/.sftp/root (user's home directory)
  • Fallback: {TempPath}/sftp/root if home directory is unavailable

** AuditLogPath defaults:

  • All platforms: ~/.sftp/logs/audit.log (user's home directory)
  • Fallback: {TempPath}/sftp/logs/audit.log if home directory is unavailable

Note: The server automatically detects the user's home directory using environment variables (HOME on Linux/macOS, USERPROFILE on Windows) and handles permission errors gracefully.


User Management

UserAccount Properties

Property Type Default Description
Username string Required User's login name
Password string Required User's password
HomeDirectory string Required User's home directory path
IsEnabled bool true Whether the account is active
CanUpload bool true Permission to upload files
CanDownload bool true Permission to download files
CanDelete bool true Permission to delete files and directories
CanCreateDirectory bool true Permission to create directories
MaxUploadBytes long 0 Maximum upload size per user (0 = unlimited)

UserManager Methods

var userManager = new UserManager();

// Add or update a user
userManager.AddOrUpdateUser(new UserAccount("john", "password123", "/home/john"));

// Get a user
var user = userManager.GetUser("john");

// Remove a user
userManager.RemoveUser("john");

// Get all users
var allUsers = userManager.GetAllUsers();

// Check permissions
bool canUpload = userManager.HasPermission("john", SftpOperation.Write);

Tested Clients

Client Version
OpenSSH OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2
PuTTY Release 0.82
WinSCP 6.3.6
FileZilla Compatible

Underlying Technology: FxSsh

This SFTP server is built on top of the FxSsh library, a lightweight SSH server implementation.

Supported Algorithms

Category Algorithms
Public Key rsa-sha2-256, rsa-sha2-512, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521
Key Exchange diffie-hellman-group14-sha256, diffie-hellman-group16-sha512, diffie-hellman-group18-sha512, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521
Encryption aes128-ctr, aes192-ctr, aes256-ctr
MAC hmac-sha2-256, hmac-sha2-512

RFC Compliance

FxSsh adheres to the following RFC documents:


License

The MIT license


Target: .NET 8

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 87 1/6/2026
1.0.1 94 1/2/2026
1.0.0 85 1/2/2026