mikaelliljedahl / freesftpsharp

SFTP server with Web Admin GUI based on FxSSH
MIT License
20 stars 3 forks source link

SftpServer (SSHServer)

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.

Current status

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

FxSsh is a lightweight SSH server side application as SSH reinforcement of GitCandy.

Features in this repo that was not in the original FxSSH

Features planned for the future

Sample

Server (Powered by this library)

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();
        }
    }
}

Client (powered by SSH.NET client)

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();
        }
    }
}

License

The MIT license