sshproxy

package module
v0.0.0-...-e7cba0c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

README

SSH Proxy

A Go library and proxy server for tunneling SSH connections over WebSockets, designed for Cloud Run apps that don't support raw TCP connections.

Architecture Diagram

Overview

SSH Proxy provides two main functions:

  1. TCP → WebSocket Proxy - Accepts TCP connections and forwards them to a WebSocket backend on Cloud Run.
  2. WebSocket → SSH Proxy - Accepts WebSocket connections and forwards them to a local SSH server implementation.

This allows you to deploy SSH services on Cloud Run by tunneling SSH traffic over HTTP/WebSocket connections.

Usage

TCP → WebSocket Proxy

Use the SSH proxy program to forward local SSH connections to a WebSocket endpoint.

You can run this in GKE Autopilot for a minimal, cost-effective and low-maintenance environment to proxy requests.

WebSocket → SSH Proxy

Create a WebSocket handler that forwards connections to a local SSH server:

// TODO: run an SSH server on :22

// Forward WebSocket connections to local SSH server at :22
http.Handle("/ssh", sshproxy.ProxyWebSocketToSSH(":22", websocket.Upgrader{
    // Accept requests from all origins; consider changing this.
    CheckOrigin: func(r *http.Request) bool { return true },
}))
http.ListenAndServe(":8080", nil)

Authentication

The proxy sends Google Cloud identity token authentication to the backend service. The backend service can be configured to only accept traffic from the proxy.

Documentation

Overview

Package sshproxy provides WebSocket transport for SSH connections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProxySSHToWebSocket

func ProxySSHToWebSocket(ctx context.Context, sshConn net.Conn, wsURL *url.URL, ts oauth2.TokenSource) error

ProxySSHToWebSocket creates a bidirectional proxy between SSH and WebSocket

func ProxyWebSocketToSSH

func ProxyWebSocketToSSH(tcpAddr string, upgrader websocket.Upgrader) http.HandlerFunc

Types

type Proxy

type Proxy struct {
	WebsocketURL string
	SSHAddr      string
}

Proxy handles SSH-to-WebSocket proxying

func NewProxy

func NewProxy(websocketURL, sshAddr string) *Proxy

NewProxy creates a new SSH proxy

func (*Proxy) Start

func (p *Proxy) Start(ctx context.Context) error

Start starts the SSH proxy server

Directories

Path Synopsis
cmd
ssh-proxy command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL