More .NET components

SFTP server

Rebex File Server can be used to easily add SFTP server capabilities to your .NET application, no matter whether you use C#, VB.NET or any other .NET language:

CSharp

// create a server instance
var server = new FileServer();

// bind SFTP (runs over SSH) to port 22
server.Bind(22, FileServerProtocol.Sftp);

// load a server private key from encrypted 'serverkey.ppk' file
server.Keys.Add(new SshPrivateKey("server-key.ppk", "password"));

// add a user (specify username, password and virtual root path)
server.Users.Add("user01", "password", @"c:\data\user01");

// start the server in the background
server.Start();

VisualBasic

' create a server instance
Dim server = New FileServer()

' bind SFTP (runs over SSH) to port 22
server.Bind(22, FileServerProtocol.Sftp)

' load a server private key from encrypted 'serverkey.ppk' file
server.Keys.Add(New SshPrivateKey("server-key.ppk", "password"))

' add a user (specify username, password and virtual root path)
server.Users.Add("user01", "password", "c:\data\user01")

' start the server in the background
server.Start()

See also

SFTP v3 and v4 #

Rebex File Server supports SFTP v3 (the most commonly supported version of SFTP) and a subset of SFTP v4 (which adds some useful features).

Virtual filesystem #

Rebex File Server presents a virtual filesystem to each user. This makes it simple to configure it so that no sensitive or unwanted data are revealed. - just confine each user to a specific directory (and its subtree) in the filesystem.

Tracking uploads and downloads #

Rebex File Server enables tracking of uploaded and downloaded files. To get notified when a file is uploaded or downloaded, register FileServer.FileUploaded event or FileServer.FileDownloaded event, respectively.

CSharp

server.FileUploaded += server_FileUploaded;
server.FileDownloaded += server_FileDownloaded;

VisualBasic

AddHandler server.FileUploaded, AddressOf Me.server_FileUploaded
AddHandler server.FileDownloaded, AddressOf Me.server_FileUploaded

Both events provide various information about the transfer, such as details about the user transferring the file, relative path from the user's root directory, bytes transferred, and so on.

CSharp

void server_FileDownloaded(object sender, FileTransferredEventArgs e)
{
    Console.WriteLine("User '{0}' downloaded file '{1}', bytes transferred: {2}",
        e.User.Name, e.FullPath, e.BytesTransferred);
}

void server_FileUploaded(object sender, FileTransferredEventArgs e)
{
    Console.WriteLine("User '{0}' uploaded file '{1}', bytes transferred: {2}",
        e.User.Name, e.FullPath, e.BytesTransferred);
}

VisualBasic

Private Sub server_FileDownloaded(ByVal sender As Object, ByVal e As FileTransferredEventArgs)
    Console.WriteLine("User '{0}' downloaded file '{1}', bytes transferred: {2}",
                      e.User.Name, e.FullPath, e.BytesTransferred)
End Sub

Private Sub server_FileUploaded(ByVal sender As Object, ByVal e As FileTransferredEventArgs)
    Console.WriteLine("User '{0}' uploaded file '{1}', bytes transferred: {2}",
                      e.User.Name, e.FullPath, e.BytesTransferred)
End Sub

Compatible with popular SFTP clients #

Our SFTP server is compatible with popular third-party SFTP clients such as WinSCP, FileZilla, OpenSSH's sftp command.

It's a perfect companion to our SFTP client library, but it works with any third-party client that supports SSH2 and SFTP v3 or SFTP v4.