Expand description
§Wish
A library for building SSH applications with TUI interfaces.
Wish enables you to create SSH servers that serve interactive terminal applications, making it easy to build:
- SSH-accessible TUI apps
- Git servers with custom interfaces
- Multi-user terminal experiences
- Secure remote access tools
§Role in charmed_rust
Wish is the SSH application layer for bubbletea programs:
- bubbletea provides the program runtime served over SSH.
- charmed_log supplies structured logging for sessions.
- demo_showcase includes an SSH mode to demonstrate remote TUIs.
§Features
- Middleware pattern: Compose handlers with chainable middleware
- PTY support: Full pseudo-terminal emulation
- Authentication: Public key, password, and keyboard-interactive auth
- BubbleTea integration: Serve TUI apps over SSH
- Logging middleware: Connection logging out of the box
- Access control: Restrict allowed commands
§Example
ⓘ
use wish::{Server, ServerBuilder};
use wish::middleware::{logging, activeterm};
#[tokio::main]
async fn main() -> Result<(), wish::Error> {
let server = ServerBuilder::new()
.address("0.0.0.0:2222")
.with_middleware(logging::middleware())
.with_middleware(activeterm::middleware())
.handler(|session| async move {
wish::println(&session, "Hello, SSH!");
})
.build()
.await?;
server.listen().await
}Re-exports§
pub use auth::AcceptAllAuth;pub use auth::AsyncCallbackAuth;pub use auth::AsyncPublicKeyAuth;pub use auth::AuthContext;pub use auth::AuthHandler;pub use auth::AuthMethod;pub use auth::AuthResult;pub use auth::AuthorizedKey;pub use auth::AuthorizedKeysAuth;pub use auth::CallbackAuth;pub use auth::CompositeAuth;pub use auth::PasswordAuth;pub use auth::PublicKeyAuth;pub use auth::PublicKeyCallbackAuth;pub use auth::RateLimitedAuth;pub use auth::SessionId;pub use bubbletea;pub use lipgloss;
Modules§
- auth
- Authentication module for Wish SSH server.
- middleware
- Built-in middleware implementations.
- prelude
- Prelude module for convenient imports.
- session
- Session management for SSH connections.
- tea
- BubbleTea integration for serving TUI apps over SSH.
Structs§
- Context
- Context passed to authentication handlers.
- Pty
- Pseudo-terminal information.
- Public
Key - A public key used for authentication.
- Russh
Config - Configuration of a server.
- Server
- SSH server for hosting applications.
- Server
Builder - Builder for creating an SSH server.
- Server
Options - Options for configuring the SSH server.
- Server
State - Shared state for all connections to a server.
- Session
- An SSH session representing a connected client.
- Window
- Window size information.
- Wish
Handler - Handler for a single SSH connection.
- Wish
Handler Factory - Factory for creating WishHandler instances.
Enums§
- Error
- Errors that can occur in the wish SSH server library.
- Session
Output - Output messages sent from Session to the SSH channel.
Functions§
- compose_
middleware - Composes multiple middleware into a single middleware.
- error
- Writes to the session’s stderr.
- errorf
- Writes formatted output to the session’s stderr.
- errorln
- Writes to the session’s stderr with a newline.
- fatal
- Writes to stderr and exits with code 1.
- fatalf
- Writes formatted output to stderr and exits with code 1.
- fatalln
- Writes to stderr with a newline and exits with code 1.
- handler
- Creates a handler from an async function.
- new_
server - Creates a new server with default options and the provided middleware.
- noop_
handler - Creates a no-op handler.
- Writes to the session’s stdout.
- printf
- Writes formatted output to the session’s stdout.
- println
- Writes to the session’s stdout with a newline.
- run_
stream - Start a single connection in the background.
- with_
address - Sets the listen address.
- with_
auth_ handler - Sets the trait-based authentication handler.
- with_
auth_ rejection_ delay - Sets the authentication rejection delay in milliseconds.
- with_
banner - Sets a static banner.
- with_
banner_ handler - Sets a dynamic banner handler.
- with_
host_ key_ path - Sets the host key path.
- with_
host_ key_ pem - Sets the host key from PEM data.
- with_
idle_ timeout - Sets the idle timeout.
- with_
keyboard_ interactive_ auth - Sets the keyboard-interactive authentication handler.
- with_
max_ auth_ attempts - Sets the maximum authentication attempts.
- with_
max_ timeout - Sets the maximum connection timeout.
- with_
middleware - Adds middleware to the server.
- with_
password_ auth - Sets the password authentication handler.
- with_
public_ key_ auth - Sets the public key authentication handler.
- with_
subsystem - Adds a subsystem handler.
- with_
version - Sets the server version string.
- write_
string - Writes a string to the session’s stdout.
Type Aliases§
- Banner
Handler - Banner handler that returns a banner based on context.
- BoxFuture
- A boxed future for async handlers.
- Handler
- Handler function type.
- Keyboard
Interactive Handler - Keyboard-interactive authentication handler.
- Middleware
- Middleware function type.
- Password
Handler - Password authentication handler.
- Public
KeyHandler - Public key authentication handler.
- Result
- A specialized
Resulttype for wish operations. - Server
Option - Option function type for configuring the server.
- Subsystem
Handler - Subsystem handler.