Skip to main content

Crate wish

Crate wish 

Source
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 auth::parse_authorized_keys;
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.
PublicKey
A public key used for authentication.
RusshConfig
Configuration of a server.
Server
SSH server for hosting applications.
ServerBuilder
Builder for creating an SSH server.
ServerOptions
Options for configuring the SSH server.
ServerState
Shared state for all connections to a server.
Session
An SSH session representing a connected client.
Window
Window size information.
WishHandler
Handler for a single SSH connection.
WishHandlerFactory
Factory for creating WishHandler instances.

Enums§

Error
Errors that can occur in the wish SSH server library.
SessionOutput
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.
print
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§

BannerHandler
Banner handler that returns a banner based on context.
BoxFuture
A boxed future for async handlers.
Handler
Handler function type.
KeyboardInteractiveHandler
Keyboard-interactive authentication handler.
Middleware
Middleware function type.
PasswordHandler
Password authentication handler.
PublicKeyHandler
Public key authentication handler.
Result
A specialized Result type for wish operations.
ServerOption
Option function type for configuring the server.
SubsystemHandler
Subsystem handler.