Metadata-Version: 2.5
Name: ssh-over-sse-gateway
Version: 0.1.0
Summary: Policy-restricted SSH TCP relay over HTTPS POST and SSE
Requires-Python: >=3.12
Requires-Dist: cryptography>=45
Requires-Dist: pyyaml<7,>=6
Requires-Dist: starlette<2,>=1.3.1
Requires-Dist: uvicorn<1,>=0.35
Description-Content-Type: text/markdown

# ssh-sse-gateway

Provide authorized SSH access through an HTTPS endpoint. Run the gateway on a
host that can reach your approved SSH destinations.

## Install

Requires Python 3.12 or newer and OpenSSH's `ssh-keygen`.

With uv:

```sh
uv tool install --python 3.12 ssh-over-sse-gateway
```

Or with pip:

```sh
pip install 'ssh-over-sse[gateway]'
```

Use `ssh-over-sse[all]` with pip to install the client command too.

## Configure

Save your configuration as `~/.config/ssh-over-sse/gateway.yaml`. Use your public
HTTPS root URL and allow each SSH destination and login username:

```yaml
server:
  audience: https://gateway.example.com
  listen: 0.0.0.0:7010
  ingress_network_restricted: true
targets:
  - host: 192.0.2.20
    ports: [22]
    ssh_users: [alice]
```

Replace the example values and restrict the file to its owner. Limit backend
access to your trusted network before setting `ingress_network_restricted: true`;
this setting acknowledges your network restrictions and does not create them.

The default listener is `127.0.0.1:7010`. With OCI providing HTTPS, the gateway
runs plain HTTP on port **7010** and needs no backend certificate. The example
above accepts ingress on all interfaces.

## Authorize users

The gateway reads public keys from its account's `~/.ssh/authorized_keys` by
default. Set `server.authorized_keys_file` if the file is elsewhere.

Supported entries are unrestricted Ed25519, RSA (2048–8192 bits), and ECDSA
(P-256, P-384, P-521) public keys. Entries with SSH restrictions such as `from=` or
`command=` are skipped. Use only keys intended to have gateway access.

All eligible keys authenticate to the gateway account. The requested destination
and SSH username must also be allowed in your configuration. The destination
server separately authorizes the user's SSH login. Private user keys stay on
users' computers.

Removing a key denies new access and ends its active connections. Restart the
gateway after changing destination permissions; restarting ends active sessions.

## Start

Validate the configuration, then start:

```sh
ssh-sse-gateway --check-config
ssh-sse-gateway
```

To use another configuration file:

```sh
ssh-sse-gateway --config /path/to/gateway.yaml --check-config
ssh-sse-gateway --config /path/to/gateway.yaml
```

Configure HTTPS ingress to forward requests to the gateway. It must pass
authorization headers and support streaming without buffering or compression.
The root URL shows a landing page in a browser. Users pass that same root URL to
`ssh-sse-cli`.

For direct HTTPS without an ingress, set `server.tls_mode: direct` and provide
`--tls-cert /path/to/cert.pem` and `--tls-key /path/to/key.pem` when starting.
Restrict the server's private certificate key to its owner.

## Check access

From a user's computer:

```sh
ssh-sse-cli --url https://gateway.example.com -i ~/.ssh/id_ecdsa check
```

Success confirms gateway key access. Users still need destination permission and
an authorized SSH login. A landing page alone does not confirm SSH access.

## Troubleshooting

If startup fails, run `--check-config` and check required values, file ownership,
and permissions. If users cannot connect, check the HTTPS route, public-key
access, destination permissions, and network reachability.

```sh
ssh-sse-gateway --help
```
