Skip to main content

ysshd

yet another ssh daemon

Features

  • Supports SSH remote forwarding (ssh -R).
  • Supports SSH local forwarding (ssh -L).
  • Authentication via standard ~/.ssh/authorized_keys.
  • Optional password authentication using bcrypt hashes (via environment variables).
  • Configurable host, port, key paths via command-line arguments.
  • Basic interactive prompt after connection.

Installation

# Ensure you have uv (https://github.com/astral-sh/uv)
# Install the package and its dependencies using uv
uv tool install ysshd

Usage

Running the Server

Once installed, you can run the server using the ysshd command:

# Run with default settings (listens on 0.0.0.0:8022)
ysshd

# Run on a different port
ysshd --port 8023

# Specify a different host key path
ysshd --server-host-key /path/to/your/host_key

# Specify a different authorized_keys file
ysshd --authorized-keys /path/to/other/authorized_keys

# Enable password authentication (requires environment variables set, see Prerequisites)
export YSSHD_ADMIN_USER="admin"
export YSSHD_ADMIN_PASSWORD="your_password_or_hash"
ysshd --enable-password-auth

# Combine options
ysshd --port 9022 --enable-password-auth

Command-Line Arguments

  • --host <ip>: IP address to listen on (default: 0.0.0.0).
  • --port <number>: Port to listen on (default: 8022).
  • --server-host-key <path>: Path to the server's private host key (default: ~/.ssh/ysshd_ed25519_key, generated if not found).
  • --authorized-keys <path>: Path to the authorized public keys file (default: ~/.ssh/authorized_keys).
  • --enable-password-auth: Boolean flag to enable password authentication (default: False). Requires YSSHD_ADMIN_USER and YSSHD_ADMIN_PASSWORD environment variables to be set (see Prerequisites).
  • --help: Display help message and exit.

Prerequisites

These steps are required before clients can connect successfully using certain authentication methods.

  1. Public Key Authentication:

    • Ensure the client user has an SSH key pair (e.g., ~/.ssh/id_ed25519 and ~/.ssh/id_ed25519.pub on their machine).
    • Add the client's public key (the content of ~/.ssh/id_ed25519.pub or similar) to the ~/.ssh/authorized_keys file on the server machine (the one running ysshd). Create the file if it doesn't exist. The default path used by ysshd is ~/.ssh/authorized_keys unless overridden by --authorized-keys.
    • Ensure permissions are correct on the server:
      chmod 700 ~/.ssh
      chmod 600 ~/.ssh/authorized_keys
      
  2. Password Authentication (Optional):

    • To enable password authentication (which requires the --enable-password-auth flag when running the server), you must set the following environment variables before starting ysshd:

      • YSSHD_ADMIN_USER: The username allowed to log in with a password.
      • YSSHD_ADMIN_PASSWORD: This variable should contain either:
        • A pre-generated bcrypt hash string (recommended for security). You can generate one using Python's bcrypt library or tools like htpasswd (ensure it outputs bcrypt format).
        • A plain-text password. If you provide plain text, ysshd will hash it on startup using bcrypt and log the generated hash (which you should then use directly in the environment variable in the future).

      Warning: Password authentication is less secure than public key authentication and is primarily intended for development or testing purposes. It is not recommended for production deployments. Always prefer public key authentication for better security.

      # Example: Setting environment variables before running ysshd
      export YSSHD_ADMIN_USER="admin"
      export YSSHD_ADMIN_PASSWORD='$2b$12$YourPreGeneratedBcryptHashHere' # Or use plain text initially
      # Now run: ysshd --enable-password-auth ...
      

Connecting with an SSH Client

Make sure the prerequisites for your chosen authentication method have been met on the server.

# Connect using public key (replace user, host, port if needed)
ssh your@server_ip -p 8022

# Connect using password (if enabled on server)
ssh admin@server_ip -p 8022
# (You will be prompted for the password)

# Set up remote forwarding (forward local port 8080 to remote port 80)
# Traffic to server_ip:8080 will be sent to localhost:80 on the client machine.
ssh your@server_ip -p 8022 -R 8080:localhost:80

# Set up local forwarding (forward local port 9000 to remote service)
# Traffic sent to localhost:9000 on the client machine will be sent
# through the SSH server to internal_service_host:80 on the server's network.
ssh your@server_ip -p 8022 -L 9000:internal_service_host:80

Metadata

Release files for ysshd 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ysshd 0.1.0
File Size Uploaded
ysshd-0.1.0.tar.gz 23.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ysshd 0.1.0
File Interpreter ABI Platform
ysshd-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.5 kB

Release files / ysshd-0.1.0.tar.gz

Download URL ysshd-0.1.0.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d233a2003d280b94b267d2898460601395f097a4e9759be36f0da7161eb3642a
BLAKE2b-256 checksum
How to use checksums
163d3e1370dcc33637f4208746fa72f4f01b03ad8aab821031c993aeeb2b0b63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.6

Release files / ysshd-0.1.0-py3-none-any.whl

Download URL ysshd-0.1.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c55a9641c082acf14e422479764e36a4486867cc88e5a2e73a0babc7bcfd6dcd
BLAKE2b-256 checksum
How to use checksums
0b06547b930bdd7fbae400361c9880727f7f3bfdf1d9451b349ab2fcc422f63a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.6

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page