Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
de638df
[skip ci] Adding proto, dependencies and required
jubeormk1 Mar 3, 2026
fd01170
[skip ci] Adding sunset-sftp crate with basic SFTP server implementation
jubeormk1 Mar 4, 2026
1f38033
[skip ci] Adding @mkj contributions troubleshooting channel reception…
jubeormk1 Mar 4, 2026
f06643c
[skip ci] WIP: Adding demo sftp std example and testing
jubeormk1 Mar 4, 2026
8b585a8
[skip ci] Improved demo sftp std testing scripts
jubeormk1 Mar 5, 2026
8ef777f
CI updated
jubeormk1 Mar 5, 2026
5259179
CI fix: cargo fmt
jubeormk1 Mar 5, 2026
19f63d4
Addressing easier some points in the review
jubeormk1 Mar 10, 2026
e8cab8c
Fixing missing points in previous commit
jubeormk1 Mar 24, 2026
6be8a2c
removing size from demo/sftp/std build outputs
jubeormk1 Mar 24, 2026
7aaa7de
Fixing unnecessary duplicated lifetimes and tidying up
jubeormk1 Mar 24, 2026
74ff19a
Reverting changes to sshwire-derive/src/lib.rs
jubeormk1 Mar 25, 2026
91c3763
Removing new(&str) from `OpaqueFileHandle`
jubeormk1 Mar 26, 2026
1feecff
RUSTSEC-2024-0436: Fixing Paste to version 1.0.25
jubeormk1 Apr 4, 2026
635b173
Fixing typo in previous commit
jubeormk1 Apr 4, 2026
45f54ff
Extra typo. Running CI now to make sure that all is good
jubeormk1 Apr 4, 2026
fbe6fc6
sftp: simplify some lifetimes
mkj Apr 12, 2026
d15ecc7
Fix formatting for "sftp: simplify lifetimes"
mkj Apr 12, 2026
a5e42fa
Fix read refcount for ChanIn and ChanInOut clone()
mkj Mar 17, 2026
5c81041
Rust 1.88 min version
mkj Apr 1, 2026
0ead867
Update some outdated dependencies
mkj Apr 1, 2026
8149c7c
Fix some clippy warnings
mkj Apr 12, 2026
9c7ce51
pretty-hex isn't needed, plain hex format instead
mkj Apr 15, 2026
6287abc
Fix url typo in readme
mkj Apr 15, 2026
10ee61d
Remove rust-toolchain files
mkj Apr 15, 2026
6dea4d6
Delete update-toolchain.sh
mkj Apr 15, 2026
477237f
[skip ci] Deleted empty default feature
jubeormk1 Apr 16, 2026
53ce64e
[skip ci] Correcting typo "peak"
jubeormk1 Apr 16, 2026
fa819f0
[skip ci] Naively adding bug to WireError
jubeormk1 Apr 16, 2026
1482278
[skip ci] Documenting generic parameters for sftp structures
jubeormk1 Apr 17, 2026
0fa5e16
Using AtomicUsize instead of Mutex in sftpoutputchannelhandler.rs
jubeormk1 Apr 17, 2026
3b37af3
SftpOutputConsumer.receive_task exits on 0 byte reads
jubeormk1 Apr 17, 2026
27c116f
sftp: Add a ParseContext to sftpsource
mkj Apr 12, 2026
7c6186e
Fixing fmt to pass CI
jubeormk1 Apr 17, 2026
aa0960c
Adding strict-path to demo/sftp/std
jubeormk1 Apr 20, 2026
906cd3d
Simplifying sftp std example. No seeds + 32 bytes handle_id
jubeormk1 Apr 22, 2026
611d792
Fixing unclear naming in OpaqueFileHandle implementation
jubeormk1 Apr 23, 2026
53cd6e8
Addressing potential integer overflow
jubeormk1 Apr 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 58 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 26 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ rust-version = "1.87"
[workspace]
members = [
"demo/picow",
"demo/std", "fuzz",
"demo/std",
"demo/sftp/std",
"fuzz",
"stdasync",
"sftp",
# workspace.dependencies paths are automatic
]

Expand All @@ -39,7 +42,9 @@ ascii = { version = "1.0", default-features = false }
arbitrary = { workspace = true, optional = true }

getrandom = "0.2"
rand_core = { version = "0.6", default-features = false, features = ["getrandom"]}
rand_core = { version = "0.6", default-features = false, features = [
"getrandom",
] }

ctr = { version = "0.9", features = ["zeroize"] }
aes = { version = "0.8", features = ["zeroize"] }
Expand All @@ -53,14 +58,27 @@ zeroize = { version = "1", default-features = false, features = ["derive"] }
cipher = { version = "0.4", features = ["zeroize"] }
subtle = { version = "2.4", default-features = false }
# ed25519/x25519
ed25519-dalek = { version = "2.1", default-features = false, features = ["zeroize", "rand_core"] }
x25519-dalek = { version = "2.0", default-features = false, features = ["zeroize"] }
curve25519-dalek = { version = "4.1", default-features = false, features = ["zeroize"] }
ml-kem = { version = "0.2.1", default-features = false, features = ["zeroize"], optional = true }
ed25519-dalek = { version = "2.1", default-features = false, features = [
"zeroize",
"rand_core",
] }
x25519-dalek = { version = "2.0", default-features = false, features = [
"zeroize",
] }
curve25519-dalek = { version = "4.1", default-features = false, features = [
"zeroize",
] }
ml-kem = { version = "0.2.1", default-features = false, features = [
"zeroize",
], optional = true }
# p521 = { version = "0.13.2", default-features = false, features = ["ecdh", "ecdsa"] }
rsa = { version = "0.9", default-features = false, optional = true, features = ["sha2"] }
rsa = { version = "0.9", default-features = false, optional = true, features = [
"sha2",
] }
# TODO: getrandom feature is a workaround for missing ssh-key dependency with rsa. fixed in pending 0.6
ssh-key = { version = "0.6", default-features = false, optional = true, features = ["getrandom"] }
ssh-key = { version = "0.6", default-features = false, optional = true, features = [
"getrandom",
] }

embedded-io = { version = "0.6", optional = true }

Expand Down
40 changes: 40 additions & 0 deletions demo/sftp/std/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[package]
name = "sunset-demo-sftp-std"
version = "0.1.2"
edition = "2021"

[dependencies]
sunset = { workspace = true, features = ["rsa", "std"] }
sunset-async.workspace = true
sunset-demo-common.workspace = true
sunset-sftp = { version = "0.1.0", path = "../../../sftp", features = ["std"] }

# 131072 was determined empirically
embassy-executor = { version = "0.7", features = [
"executor-thread", "arch-std", "log", "task-arena-size-131072"] }
embassy-net = { version = "0.7", features = ["tcp", "dhcpv4", "medium-ethernet"] }
embassy-net-tuntap = { version = "0.1" }
embassy-sync = { version = "0.7" }
embassy-futures = { version = "0.1" }
# embassy-time dep required to link a time driver
embassy-time = { version = "0.4", default-features=false, features = ["log", "std"] }

log = { version = "0.4" }
# default regex feature is huge
env_logger = { version = "0.11", default-features=false, features = ["auto-color", "humantime"] }

embedded-io-async = "0.6"
heapless = "0.8"

# for tuntap
libc = "0.2.101"
async-io = "1.6.0"

# using local fork
# menu = "0.3"


critical-section = "1.1"
rand = { version = "0.8", default-features = false, features = ["getrandom"] }
sha2 = { version = "0.10", default-features = false }
fnv = "1.0.7"
64 changes: 64 additions & 0 deletions demo/sftp/std/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# sunset-demo-sftp-std

`demo/sftp/std` contains a host-side (`std`) demo that runs an SSH server with SFTP support using the `sunset` and `sunset-sftp` crates. It runs on linux distributions.

It is intended as a **reference implementation** for building your own SFTP server with `sunset-sftp`. It is not a complete implementation and you should make your own choices for your sftp server.

In particular, this demo shows how to:

- implement an `SftpServer` for request handling
- add a `FileHandleManager` to track/open/close active handles
- define an `OpaqueFileHandle` format to safely encode/decode handle IDs across requests

Use `src/demosftpserver.rs`, `src/demofilehandlemanager.rs`, and `src/demoopaquefilehandle.rs` together with `main.rs` and common demo files as a reference for custom server development.

## What this folder contains

- `src/main.rs`
Demo entry point. Sets up logging, runtime/executor, network stack, and starts the SSH/SFTP demo server.
- `src/demosftpserver.rs`
Demo SFTP server wiring and request handling glue.
- `src/demofilehandlemanager.rs`
Tracks and manages open file handles used by the SFTP session.
- `src/demoopaquefilehandle.rs`
Defines/encodes opaque file handle values used by the demo protocol layer.
- `tap.sh`
Helper script to create/configure a TAP interface for local testing.
- `debug_sftp_client.sh`
Convenience script for running an SFTP client in a debug-friendly way.
- `testing/`
Test and log scripts (read/write/stat/readdir scenarios, log helpers, and parsing utilities).

## Setup

This demo uses a tap interface to run the server and accept connections. The tap.sh sets this up in a linux environment. I have not find a way to run this on MacOS. On windows I recommend using WSL2.

Run:

```bash
sudo ./tap.sh
```

## Build / run

From base project folder `sunset`:

```bash
cargo run -p sunset-demo-sftp-std
```

Then connect with an SFTP client using the configured demo host/user settings. The first info log will display the server ipv4 address.

## Testing

`testing/` contains runnable scripts and utilities to validate SFTP behavior end-to-end. It includes scenarios for:

- file reads/writes
- `stat`/metadata checks
- directory listing (`readdir`)
- log capture and parsing helpers (Requires a tshark installation with the current user in wireshark group)

These scripts are useful both for regression checks and as examples of expected server behavior during development.

these scripts have been used through the development of `sunset-sftp` and might not respond to a general use but some particular troubleshooting. I hope that they are useful as a reference for you exploration.

5 changes: 5 additions & 0 deletions demo/sftp/std/debug_sftp_client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# This sftp options are meant to help debugging and do not store any host key or known hosts information.
# That is not a good practice in real life, as it can lead to security issues, but it is useful for debugging purposes.

sftp -vvv -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR any@192.168.69.2
3 changes: 3 additions & 0 deletions demo/sftp/std/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "stable"
components = [ "rustfmt" ]
Loading
Loading