Rospo Documentation

repository·main·Indexed 18 days ago

https://github.com/ferama/rospo

Rospo is a single binary tool for creating secure, reliable SSH tunnels, supporting forward and reverse tunnels, jump hosts, and SOCKS/DNS proxies. It provides both client and server (sshd) functionalities and can be configured via CLI or YAML files. Compatible with macOS, GNU/Linux, Windows 10+, and Docker.

Tokens
9.8K
Snippets
43
Records
48
Agent score
63%

What's inside rospo

  1. Install Rospo

    main

    Rospo is a single binary tool for creating secure SSH tunnels. It supports macOS, GNU/Linux, Windows 10+, and Docker.

    macOS

    Install via Homebrew:

    brew install rospo

    GNU/Linux

    Download the appropriate binary from the GitHub releases page:

    • amd64: https://github.com/ferama/rospo/releases/latest/download/rospo-linux-amd64
    • arm64: https://github.com/ferama/rospo/releases/latest/download/rospo-linux-arm64
    • arm: https://github.com/ferama/rospo/releases/latest/download/rospo-linux-arm

    Microsoft Windows

    Download the amd64 executable: https://github.com/ferama/rospo/releases/latest/download/rospo-windows-amd64.exe

    Docker

    Run the containerized version:

    docker run ghcr.io/ferama/rospo --help
    brew install rospo
  2. Quick command line usage

    main

    Rospo can be used via CLI for simple tasks or via a YAML configuration file for complex scenarios. It supports both key-based and password-based authentication (key-based is preferred).

    Reverse Shell

    Starts an embedded SSH server and reverse proxies a port (default 2222) to a remote server:

    rospo revshell user@server:port

    Tunneling

    Forward a local port to a remote port on a remote server:

    rospo tun forward -l :5000 -r :6000 user@server:port

    Running with Configuration

    For complex setups involving multiple tunnels, jump hosts, or SOCKS proxies, use a YAML config file:

    rospo run config.yaml

    Help

    Get detailed help for specific subcommands:

    rospo tun forward --help
    rospo tun reverse --help
    rospo sshd --help
    rospo revshell user@server:port
  3. Run Rospo as a Windows Service

    main

    You can install Rospo as a persistent Windows service to ensure tunnels start automatically with the machine. This requires Administrative privileges in PowerShell.

    1. Create a configuration file

    Example C:\conf.yaml for Remote Desktop (RDP):

    sshclient:
      server: your-rospo-or-sshd-server-uri:2222
      identity: "c:\\absolute_path_to_your\\id_rsa"
      known_hosts: "C:\\absolute_path_to_your\\known_hosts"
    
    tunnel:
      - remote: ":3389"
        local: ":3389"
        forward: false

    2. Manage the service via sc.exe

    Create the service:

    sc.exe create rospo start= auto DisplayName= Rospo binpath= "C:\rospo.exe run C:\conf.yaml"

    Start the service:

    sc.exe start rospo

    Check status:

    sc.exe query rospo

    Stop and delete the service:

    sc.exe stop rospo; sc.exe delete rospo
    sc.exe create rospo start= auto DisplayName= Rospo binpath= "C:\rospo.exe run C:\conf.yaml"
  4. Install rospo via Homebrew

    main

    To install rospo on macOS or Linux using Homebrew, first ensure Homebrew is installed, then use the brew install command.

    # Install Homebrew
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
    # Install rospo
    brew install rospo
  5. Run Rospo as an SSHD using Docker Compose

    main

    To run Rospo in an SSH daemon (sshd) mode using Docker Compose, follow these steps to prepare your keys and authorized users:

    1. Generate server keys: Use the keygen command to create the necessary server keys.
    2. Prepare authorized_keys: Create an authorized_keys file in your working directory to manage allowed SSH keys.
    3. Start the container: Use docker compose to launch the service in detached mode.

    Note: Ensure your docker-compose.yml is configured to mount the generated keys and the authorized_keys file into the container.

    # 1. Generate keys
    rospo keygen -n server_key -s
    
    # 2. Create authorized_keys
    touch authorized_keys
    
    # 3. Run with docker compose
    docker compose up -d
  6. Use the rospo CLI

    main

    Rospo is a tool designed to create reliable SSH tunnels. It is invoked via the rospo command and requires at least one subcommand to function. If no valid subcommand is provided, the CLI will exit with an error.

    # Basic usage requires a subcommand
    rospo <subcommand> [args]
  7. Configure complex tunnels with YAML

    main

    For advanced use cases, create a config.yaml file. This allows you to define multiple tunnels, jump hosts, and SOCKS proxies in a single execution.

    Configuration Structure

    • sshclient: Defines the primary connection parameters (server, identity, known_hosts, jump_hosts).
    • tunnel: A list of tunnel definitions. Each can specify remote, local, forward (boolean), and an optional override sshclient for per-tunnel connection settings.
    • socksproxy: Configures a SOCKS proxy with a listen_address and a dedicated sshclient.

    Example Configuration

    sshclient:
      server: myuser@remote_server_address
      identity: "~/.ssh/id_rsa"
      jump_hosts:
        - uri: "anotheruser@jumphost_address"
          identity: "~/.ssh/id_rsa"
    
    tunnel:
      - remote: ":8000"
        local: ":8000"
        forward: yes
      - remote: ":9999"
        local: ":9999"
        forward: yes
      - remote: ":5000"
        local: ":5000"
        forward: no
        sshclient:
          server: myuser@another_server
          identity: "~/another_identity"
    
    socksproxy:
      listen_address: ":1080"
      sshclient:
        server: localhost:9999
    rospo run config.yaml
  8. How jump hosts are resolved in Rospo

    main

    Rospo supports traversing multiple jump hosts to reach a target server. The resolution logic follows these rules:

    1. SSH Config Integration: If you provide a --jump-host that matches a host entry in your local SSH configuration, Rospo will recursively resolve the ProxyJump chain defined in that config.
    2. Identity Inheritance: As Rospo traverses the jump host chain, it uses the identity file associated with each host in the configuration.
    3. Command Line Overrides: If you explicitly provide a flag (like --user-identity or --jump-host), the command line value takes precedence over values found in the SSH configuration file.
    4. Final Hop: After resolving the chain from the SSH config, the final --jump-host provided on the command line is appended to the jump host list to complete the connection path.
  9. Deploy Rospo using Docker Compose

    main

    You can deploy Rospo as a Docker container using a compose.yaml file. The service is configured to run in host network mode, which is necessary for Rospo to manage network connections as intended. The container requires a configuration file (/rospo.yaml) and several key files for authentication to be mounted as volumes.

    services:
      rospo:
        restart: unless-stopped
        image: ghcr.io/ferama/rospo:main
        container_name: rospo
        command:
          - run
          - /rospo.yaml
        network_mode: "host"
        logging:
          driver: json-file
          options:
            max-size: "8m"
        volumes:
          - ./rospo.yaml:/rospo.yaml
          - ./server_key:/server_key
          - ./authorized_keys:/authorized_keys
          - ./server_key.pub:/server_key.pub
  10. Configure port tunnels

    main

    The tunnel section allows you to define multiple port forwarding rules. This section requires the sshclient section to be configured, as it uses that connection to establish the tunnels.

    Each tunnel entry supports:

    • remote: The remote port or address (e.g., ":8000").
    • local: The local port or address (e.g., ":8000" or "my-local-reachable-service:8080").
    • forward:
      • If yes (or true): Performs standard local port forwarding (local port is forwarded to the remote server).
      • If no (or false): Performs reverse port forwarding (remote port is forwarded to the local machine).
    • sshclient (OPTIONAL): A dedicated sshclient for this specific tunnel.
    tunnel:
      # Standard local forward
      - remote: ":8000"
        local: ":8000"
        forward: yes
    
      # Reverse tunnel: maps remote :5432 to local :5432
      - remote: ":5432"
        local: ":5432"
        forward: no
    
      # Reverse tunnel: maps remote :8080 to a specific local service
      - remote: ":8080"
        local: "my-local-reachable-service:8080"
        forward: false
  11. Configure Rospo Docker volumes and command

    main

    When running Rospo in Docker, the following volume mappings and command arguments are used to provide the necessary configuration and security credentials:

    Required Volumes

    • ./rospo.yaml:/rospo.yaml: The main Rospo configuration file.
    • ./server_key:/server_key: The server's private key.
    • ./server_key.pub:/server_key.pub: The server's public key.
    • ./authorized_keys:/authorized_keys: The file containing authorized keys for access control.

    Execution Command

    The container executes the run command pointing to the configuration file: run /rospo.yaml