Sftp Server implementation based on SSHServer library based heavily on FxSsh. This fork (based on https://github.com/0xFireball/SSHServer) implements the sftp subsystem and a Graphical user interface for administration of users and server settings.
All basic Sftp command are now implemented except handling symbolic links. However some implementations such as returning correct file attributes are not finalized. Server was tested with FileZilla client only. There are probably some bugs left to fix. You are welcome to create PR's
FxSsh is a lightweight SSH server side application as SSH reinforcement of GitCandy.
- Password Authentication is implemented and enabled by default
- Public Key authentication relying on key fingerprint
- Server key is autogenerated at first startup time
- Logging based on Serilog.
- SFTP subsystem added.
- Running commands remotely is disabled by default (code is commented out but will later be a setting per user)
- Server is started using IHostedService interface (useful for standalone service or hosted inside Asp.Net Core)
- Server settings are saved in a LiteDb-database file.
- whitelist IP/ip-range (CIDR) per account. (Implemented in server but not in the admin UI)
- Ban IP, auto-ban on multiple failed attempts to login
- Option to use cloud Blob storage as sftp root. Filesystem will be an interface in the SFTP engine, then both local file system or blob storage can be used. Controlled using Dependency Injection
- Different ways to store settings and users (using Dependency Injection). E.g. Azure SQL, SQLite, JSON, LiteDb
- SCP subsystem
using FxSsh;
using FxSsh.Services;
using System;
using System.Text;
using System.Threading.Tasks;
namespace SshServerLoader
{
class Program
{
static async Task Main(string[] args)
{
await new HostBuilder()
.ConfigureServices((hostContext, services) =>
{
services.AddLogging();
Log.Information("Starting host service");
services.AddHostedService<HostedSftpServer>();
})
.RunConsoleAsync();
}
}
}
using Renci.SshNet;
using System;
using System.Net;
namespace TestClient
{
internal class Program
{
private static void Main(string[] args)
{
var testUsername = "test_person";
var testPassword = "1234";
var connInfo = new ConnectionInfo(IPAddress.Loopback.ToString(), 22, testUsername,
new AuthenticationMethod[]
{
// Password auth
new PasswordAuthenticationMethod(testUsername, testPassword)
}
);
using var sftpclient = new SftpClient(connInfo);
sftpclient.Connect();
sftpclient.ListDirectory("/");
sftpclient.Disconnect();
Console.ReadLine();
}
}
}
The MIT license