{"id":15011699,"url":"https://github.com/keensystemsnl/sftpserver","last_synced_at":"2025-04-12T03:31:57.302Z","repository":{"id":69245658,"uuid":"494519320","full_name":"KeenSystemsNL/SFTPServer","owner":"KeenSystemsNL","description":".Net SFTP Server implementation","archived":false,"fork":false,"pushed_at":"2022-11-15T15:56:33.000Z","size":169,"stargazers_count":18,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T23:34:46.635Z","etag":null,"topics":["cross-platform","csharp","dotnet","dotnet-standard2-1","dotnet6","linux","macos","mit-license","nuget-package","openssh","openssh-server","sftp","sftp-server","ssh","windows"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KeenSystemsNL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-20T15:38:04.000Z","updated_at":"2025-01-22T13:22:43.000Z","dependencies_parsed_at":"2024-06-11T06:45:21.437Z","dependency_job_id":null,"html_url":"https://github.com/KeenSystemsNL/SFTPServer","commit_stats":{"total_commits":69,"total_committers":1,"mean_commits":69.0,"dds":0.0,"last_synced_commit":"1e8afc12d09209c53a23fb748141dd7606527d95"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeenSystemsNL%2FSFTPServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeenSystemsNL%2FSFTPServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeenSystemsNL%2FSFTPServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeenSystemsNL%2FSFTPServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KeenSystemsNL","download_url":"https://codeload.github.com/KeenSystemsNL/SFTPServer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248512797,"owners_count":21116681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-platform","csharp","dotnet","dotnet-standard2-1","dotnet6","linux","macos","mit-license","nuget-package","openssh","openssh-server","sftp","sftp-server","ssh","windows"],"created_at":"2024-09-24T19:41:28.191Z","updated_at":"2025-04-12T03:31:57.048Z","avatar_url":"https://github.com/KeenSystemsNL.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SFTPServer\n\nThis library (and simple host) implement an SFTP server that implements the [V3 version of the SFTP protocol](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02) and is available as [NuGet package](https://www.nuget.org/packages/SFTPServer/).\n\nThis library is intended to be hosted in an SSH deamon; this can be done by editting the `sshd_config` file (usually in `/etc/ssh/` or, for Windows, in `%PROGRAMDATA%\\ssh`) and pointing it to your own host executable.\n\nIn `sshd_config` you'll find the `Subsystem` entry which can be pointed to any executable:\n```\n# override default of no subsystems\n#Subsystem\tsftp\tsftp-server.exe\n#Subsystem\tsftp\tinternal-sftp\nSubsystem\tsftp\t/path/to/your/sftphost.exe\n```\n\nThe way SFTP works is that first an SSH connection is established; once that is done and a request is made for sftp, SSH will launch the configured executable under the connected user's account. All communication is done over `stdin` and `stdout`. The `SFTPServer` class takes 2 [`Streams`](https://docs.microsoft.com/en-us/dotnet/api/system.io.stream) and optionally an `ISFTPHandler` on which the SFTP commands will be invoked. This package comes with a `DefaultSFTPHandler` which provides basic I/O on the hosts's filesystem (based on a rootdirectory), but it should be pretty easy to implement your own `ISFTPHandler` so you can, for example, implement a virtual filesystem.\n\nThe `SFTPHost` project in this repository demonstrates how to simply build an executable that hosts an `SFTPServer` instance. A new `SFTPServer` is launched by the SSH service for each connection.\n\n## Implementing an `ISFTPHandler`\n\nImplementing an `ISFTPHandler` should be pretty straightforward, simply implement the `ISFTPHandler` interface. Exceptions you might want to throw should, ideally, be inherited from the `HandlerException`. This library comes with a few built-in exceptions in the `SFTP.Exceptions` namespace. Exceptions that are not inherited from the `HandlerException` will be returned to the client as [`Failure` (`SSH_FX_FAILURE`)](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#page-20). For an example implementation you can have a look at the `DefaultSFTPHandler`.\n\n## Known issues and limitations\n\n* Note that this library only implements V3; higher versions are not supported. Clients connecting with a higher version will be negotiated down to V3.\n\n* The [`SymLink`](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.10) command has been implemented with the `linkpath` and `targetpath` swapped; We may or may not interpret the RFC incorrectly (Update: [We didn't](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-09#:~:text=many%0A%20%20%20%20%20%20implementation%20implemented%20SYMLINK%20with%20the%20arguments%20reversed)) or the clients which were used to test the `SymLink` command (WinSCP, Cyberduck and the 'native' sftp commandline executable) had the arguments swapped. The `SymLink` and `ReadLink` methods are only available from .Net 6.0 upwards.\n\n* The `DefaultSFTPHandler` **DOES NOT** take particular much care of path canonicalization or mitigations against path traversion. When used in an untrusted environment extra care should be taken to ensure safety.\n\n* The `DefaultSFTPHandler` **DOES NOT** make a noteworthy effort to return correct POSIX file permissions, nor does it support setting permissions.\n\n## License\n\nLicensed under MIT license. See [LICENSE](https://github.com/KeenSystemsNL/SFTPServer/raw/master/LICENSE) for details.\n\n### Attributions\n\n[Logo / icon by Alexiuz AS](https://icon-icons.com/icon/sftp/117855) ([Archived](https://web.archive.org/web/20220520155358/https://icon-icons.com/icon/sftp/117855))","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeensystemsnl%2Fsftpserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeensystemsnl%2Fsftpserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeensystemsnl%2Fsftpserver/lists"}