Hello, we have not been providing .NET CF samples for several years. However, Rebex API in the legacy .NET CF edition is a very big subset of the mainstream edition API, so mainstream edition samples can be adapted to .NET CF easily.
However, in order to launch an SFTP server, you really don't need much code beyond this. For example, try this to get started:
public static void Main()
{
// port to listen at
int port = 8022;
// server's private key
var key = new SshPrivateKey("key.ppk", "password");
// set up a user with one of several file system providers
var user01 = new FileServerUser("user01", "password", @"\Hard Disk\SFTP\user01");
// create a server instance
var server = new FileServer();
// bind SFTP/SSH and SSH shell to port 8022
server.Bind(port, FileServerProtocol.Sftp);
server.Bind(port, FileServerProtocol.Shell);
// add server key
server.Keys.Add(key);
// add a user
server.Users.Add(user01);
// use console log writer
server.LogWriter = new ConsoleLogWriter(LogLevel.Info);
// start server in the background
server.Start();
// run the server
Console.WriteLine("Server is listening at port {0}", port);
Console.WriteLine("Press 'Enter' to stop.");
Console.ReadLine();
// stop the server
server.Stop();
Console.WriteLine("Server has been stopped.");
}
To generate the key.ppk
file, use SshPrivateKey class.
And to enable tunneling, just bind the appropriate subsystem and add an event handler.
However, please note that Rebex SSH server currently only supports outgoing SSH tunnels. Support for incoming tunnels is planned for one of the future releases.