1
0
Fork 0
mirror of https://github.com/imjasonh/ssh-proxy synced 2026-07-07 00:23:33 +00:00
No description
Find a file
Jason Hall b0a060fc67 update diagram
Signed-off-by: Jason Hall <jason@chainguard.dev>
2025-09-13 22:49:28 -04:00
cmd/ssh-proxy proxy doesn't need the host key, it's just a TCP proxy 2025-09-13 22:44:05 -04:00
diagram.png update diagram 2025-09-13 22:49:28 -04:00
go.mod proxy doesn't need the host key, it's just a TCP proxy 2025-09-13 22:44:05 -04:00
go.sum proxy doesn't need the host key, it's just a TCP proxy 2025-09-13 22:44:05 -04:00
LICENSE add license 2025-09-11 12:47:04 -04:00
proxy.go proxy doesn't need the host key, it's just a TCP proxy 2025-09-13 22:44:05 -04:00
proxy_test.go actually add tests 2025-09-12 12:20:50 -04:00
README.md proxy doesn't need the host key, it's just a TCP proxy 2025-09-13 22:44:05 -04:00
websocket.go simplify and provide ProxySSHToWebSocket as a func too 2025-09-12 11:54:40 -04:00
websocket_test.go update readme 2025-09-12 12:35:53 -04:00

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. SSH → WebSocket Proxy - Accepts SSH 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

SSH → WebSocket Proxy

Use the SSH proxy command 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:

import (
    "net/http"
    "github.com/gorilla/websocket"
    sshproxy "github.com/imjasonh/ssh-proxy"
)

upgrader := websocket.Upgrader{
    // Accept requests from all origins; consider changing this.
    CheckOrigin: func(r *http.Request) bool { return true },
}

// Forward WebSocket connections to local SSH server at :22
http.Handle("/ssh", sshproxy.ProxyWebSocketToSSH(":22", upgrader))
http.ListenAndServe(":8080", nil)

Authentication

The SSH proxy supports Google Cloud identity token authentication for secure WebSocket connections. When connecting to Cloud Run services, the proxy automatically obtains and includes identity tokens in the Authorization header.