Skip to content

Conversation

@handewo
Copy link

@handewo handewo commented Aug 4, 2025

This PR adds an experimental no-tty Cargo feature that allows the crate to be used in some environments where spawning a new pseudo-terminal (PTY) per session is impossible—e.g. when using Tokio, which does not support fork.

Background & Motivation

  • The russh ecosystem is async-only today.
  • Tokio’s runtime is not fork-safe, so we cannot allocate a new PTY for every incoming SSH session inside the async worker.
  • Without this feature, downstream users who only need exec/subsystem channels (and never interactive shells) are blocked from adopting the library.

Key Changes

  • Added optional feature no-tty in Cargo.toml.
  • Gate all PTY allocation logic behind #[cfg(not(feature = "no-tty"))].
  • Provide stub implementations that return ChannelFailure when a client requests a PTY while the feature is active.
  • Added examples/ssh-service.rs that starts a minimal async SSH server with no-tty enabled for quick testing.

Testing

  1. Check out this branch
  2. cargo run --example ssh-service --features no-tty
  3. Connect with any SSH client:
    ssh 127.0.0.1 -p 2222 -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no"

- Support no-tty mode for some special situation.
- examples/ssh-service.rs is a demo of `no-tty` features
@handewo handewo requested a review from TimonPost as a code owner August 4, 2025 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant