Sign inSign up

shine09/ssh-client-websocat

By shine09

•Updated over 1 year ago

Image
0

210

shine09/ssh-client-websocat repository overview

⁠Overview (English)

The shine09/ssh-client-websocat:latest Docker image is a lightweight solution for establishing secure SSH tunnels over WebSocket connections using websocat. It is designed for scenarios requiring secure port forwarding to remote services through a WebSocket proxy, such as in restricted network environments.

⁠Features

  • SSH Tunneling: Enables secure local port forwarding to remote services (e.g., MySQL, RDP).
  • Websocat Proxy: Uses websocat to connect via WebSocket (wss://) for SSH tunneling.
  • Configurable: Supports custom SSH configurations and key files via volume mounts.
  • Reliable: Includes keep-alive settings for stable, long-running SSH connections.

⁠Usage Example

⁠docker-compose.yaml
services:
  ssh-forward:
    image: shine09/ssh-client-websocat:latest
    container_name: ssh-forward
    restart: always
    volumes:
      - /Users/shine/.ssh/config-ssh-forward:/root/.ssh/config:ro
      - /Users/shine/.ssh/id_ed25519:/root/.ssh/id_ed25519:ro
      - /Users/shine/.ssh/id_ed25519.pub:/root/.ssh/id_ed25519.pub:ro
    command: ["ssh", "-v", "-N", "-o", "ExitOnForwardFailure=yes", "-o", "StrictHostKeyChecking=no", "forward.service"]
    ports:
      - 10000:10000
      - 10042:10042
⁠/Users/shine/.ssh/config-ssh-forward
Host forward.service
  User root
  ProxyCommand websocat --binary -k wss://my-self-server-1.example.com
  PreferredAuthentications publickey
  IdentitiesOnly yes
  RequestTTY no
  ServerAliveInterval 10
  ServerAliveCountMax 3
  TCPKeepAlive yes
  IdentityFile ~/.ssh/id_ed25519
  LocalForward 0.0.0.0:10000 172.1.1.130:3306
  LocalForward 0.0.0.0:10042 172.2.2.21:3389

⁠Setup Instructions

  1. Create an SSH configuration file (e.g., config-ssh-forward) with your WebSocket proxy and port forwarding details.
  2. Ensure your SSH private and public keys (e.g., id_ed25519, id_ed25519.pub) are available.
  3. Use the provided docker-compose.yaml to run the container, mounting the configuration and key files.
  4. The container forwards local ports (e.g., 10000 for MySQL, 10042 for RDP) to the specified remote hosts.

⁠概述 (中文)

shine09/ssh-client-websocat:latest Docker 镜像是一个轻量级解决方案,用于通过 websocat 借助 WebSocket 连接建立安全的 SSH 隧道。它适用于需要在受限网络环境中通过 WebSocket 代理进行安全端口转发的场景。

⁠功能

  • SSH 隧道:支持将本地端口安全转发到远程服务(如 MySQL、RDP)。
  • Websocat 代理:通过 websocat 使用 WebSocket (wss://) 协议进行 SSH 连接。
  • 可配置:通过挂载支持自定义 SSH 配置文件和密钥文件。
  • 高可靠性:包含保活设置,确保长期运行的 SSH 连接稳定。

⁠使用示例

⁠docker-compose.yaml
services:
  ssh-forward:
    image: shine09/ssh-client-websocat:latest
    container_name: ssh-forward
    restart: always
    volumes:
      - /Users/shine/.ssh/config-ssh-forward:/root/.ssh/config:ro
      - /Users/shine/.ssh/id_ed25519:/root/.ssh/id_ed25519:ro
      - /Users/shine/.ssh/id_ed25519.pub:/root/.ssh/id_ed25519.pub:ro
    command: ["ssh", "-v", "-N", "-o", "ExitOnForwardFailure=yes", "-o", "StrictHostKeyChecking=no", "forward.service"]
    ports:
      - 10000:10000
      - 10042:10042
⁠/Users/shine/.ssh/config-ssh-forward
Host forward.service
  User root
  ProxyCommand websocat --binary -k wss://my-self-server-1.example.com
  PreferredAuthentications publickey
  IdentitiesOnly yes
  RequestTTY no
  ServerAliveInterval 10
  ServerAliveCountMax 3
  TCPKeepAlive yes
  IdentityFile ~/.ssh/id_ed25519
  LocalForward 0.0.0.0:10000 172.1.1.130:3306
  LocalForward 0.0.0.0:10042 172.2.2.21:3389

⁠设置步骤

  1. 创建 SSH 配置文件(例如 config-ssh-forward),指定 WebSocket 代理和端口转发详情。
  2. 确保 SSH 私钥和公钥(例如 id_ed25519、id_ed25519.pub)已准备好。
  3. 使用提供的 docker-compose.yaml 运行容器,挂载配置文件和密钥文件。
  4. 容器会将本地端口(例如 MySQL 的 10000 端口、RDP 的 10042 端口)转发到指定的远程主机。

⁠Usage example

docker-compose.yaml :

services:
  ssh-forward:
    image: shine09/ssh-client-websocat:latest
    container_name: ssh-forward
    restart: always
    volumes:
      - /Users/shine/.ssh/config-ssh-forward:/root/.ssh/config:ro
      - /Users/shine/.ssh/id_ed25519:/root/.ssh/id_ed25519:ro
      - /Users/shine/.ssh/id_ed25519.pub:/root/.ssh/id_ed25519.pub:ro

    command: [ "ssh", "-v", "-N", "-o", "ExitOnForwardFailure=yes", "-o", "StrictHostKeyChecking=no", "forward.service" ]
    ports:
      - 10000:10000
      - 10042:10042

/Users/shine/.ssh/config-ssh-forward :

Host forward.service.work
   User root
   ProxyCommand websocat --binary -k wss://my-self-server-1.example.com
   PreferredAuthentications publickey
   IdentitiesOnly yes
   RequestTTY no
   ServerAliveInterval 10
   ServerAliveCountMax 3
   TCPKeepAlive yes
   IdentityFile ~/.ssh/id_ed25519

   LocalForward 0.0.0.0:10000 172.1.1.130:3306
   LocalForward 0.0.0.0:10042 172.2.2.21:3389

Tag summary

Content type

Image

Digest

sha256:bc0342325…

Size

11.7 MB

Last updated

over 1 year ago

docker pull shine09/ssh-client-websocat