werbot connect
werbot connect opens local ports that reach tcp, udp and other port resources through a gateway.
werbot connect [flags] [<local_port>:]<resource>[:<target_port>] ...werbot connect --gateway gw.example.com --login alice pgpsql -h 127.0.0.1 -p 5432It opens a local port per resource on 127.0.0.1 and prints <resource> → 127.0.0.1:<port> (tcp|udp).
Variables and flags WERBOT_CONNECT_GATEWAY (--gateway, required, host[:port], port defaults to 2222, or a ws:///wss:// URL: see WebSocket) and WERBOT_CONNECT_LOGIN (--login, required): see configuration.md.
Other flags: -i <key> (otherwise the ssh-agent at SSH_AUTH_SOCK when it answers, otherwise ~/.ssh/id_ed25519; an encrypted key file fails with key <path> is encrypted; load it into ssh-agent; the agent is never forwarded) and --known-hosts <path> (default ~/.ssh/known_hosts).
- Each resource gets its own SSH connection as
<login>+<resource>. The client asksresource@werbot.comfor the resource and opens a UDP port when it has thedatagramkind, otherwise a TCP port forstream(otherwiseResource <resource> does not support port access). - Target port:
:<target_port>, or the only port of the resource. A resource without ports, with several ports or with a range needs:<target_port>(resource web has several ports (8000-8002); use web:<port>). - Local port:
<local_port>, or the target port, plus 10000 below 1024 (23becomes10023,53becomes10053). A busy port fails withlocal port <n> is busy; use <free>:<resource>. - The port listens on
127.0.0.1only, but, as withssh -L, every local user of the machine can connect to it. - Each TCP connection opens its own
direct-tcpipchannel (one gateway session, one access check) and passes half-closes on. - A UDP port uses one
datagram@werbot.comchannel where each client address is a flow (at most 32; a new address beyond them is dropped until a flow has had no traffic for 2 minutes). The client frees a flow after 2 minutes whatever the resource’sflow_idle: withflow_idleabove 2 minutes and many client addresses, the gateway still holds the old flows, so its 32-flow cap can drop new flows until they age out. - After a refused or failed channel open, datagrams are dropped for a backoff of 1 s doubling up to 30 s, and the same text is printed once.
- Gateway texts (
Access denied,Gateway is busy, try again later, …) are printed as they are. A refused resource exits with code 1; Ctrl+C closes everything with code 0.
Examples:
werbot connect pg # TCP: psql -h 127.0.0.1 -p 5432werbot connect router # Telnet resource (port 23): telnet 127.0.0.1 10023werbot connect dns # UDP (port 53): dig @127.0.0.1 -p 10053 example.comWith werbot login
Section titled “With werbot login”After werbot login the login, the gateway, the key and known_hosts come from the profile, so werbot connect pg is enough. The gateway is the address of the resources’ pool; resources in different pools need --gateway. The key is the profile certificate (renewed on each reconnect); -i and --known-hosts override the profile. Without a profile werbot connect works as described above.
WebSocket
Section titled “WebSocket”When the SSH port of the gateway is blocked (a corporate network, a balancer that passes only HTTPS), the client reaches the gateway’s WebSocket input instead. SSH runs inside the WebSocket unchanged, with the same login, MFA, host key check and policy.
werbot connect --gateway wss://gw.example.com/v1/ssh --login alice pg--gateway wss://host[:port][/path](orws://) uses only the WebSocket; the path defaults to/v1/sshonly when the URL has none (wss://gw.example.com/keeps/), the port to443(wss) or80(ws).- With
werbot loginthe client takes the pool’sssh_addressandws_urlfrom the profile. It dials the SSH address first (5 s), then the WebSocket URL (10 s). A pool with only aws_urlgoes straight to the WebSocket. When both fail:gateway unreachable: ssh <addr>: <err>; websocket <url>: <err>. The choice is made again on every reconnect. HTTPS_PROXY(andHTTP_PROXY,NO_PROXY) apply to the WebSocket:wss://goes through the proxy’sCONNECT. Aws://URL through a plain HTTP proxy fails; usewss://.- The gateway host key is checked inside SSH as described in Host keys: under the SSH address when the pool has one, else under the URL’s
host:port([gw.example.com]:443inknown_hosts). A balancer that terminates TLS cannot stand in for the gateway. - OpenSSH and
werbot sshreach a WebSocket-only pool throughwerbot proxy.
Virtual network
Section titled “Virtual network”sudo werbot connect --vnet gives every resource an address and a name <resource>.<org>.werbot instead of local ports, for TCP and UDP, on Linux and macOS: see vnet.md.
Without the client
Section titled “Without the client”TCP and Telnet need no client: ssh -L <port>:<resource>:<port> <login>+<resource>@<gateway> -p 2222, then connect to 127.0.0.1:<port> (for Telnet, telnet 127.0.0.1 2323 after -L 2323:<resource>:23). The resource must be a tcp or telnet type, or an ssh resource with port_forwarding. UDP works only through werbot connect.
Host keys
Section titled “Host keys”The gateway host key is checked like OpenSSH StrictHostKeyChecking=accept-new: an unknown key is appended to known_hosts (created 0700/0600); a different key fails with host key mismatch for <host:port>. All instances of a pool share one host key.
Reconnects
Section titled “Reconnects”A keepalive@openssh.com goes every 30 s; three unanswered in a row count as a drop. After a drop the client dials again with a backoff of 1 s doubling up to 30 s while the local ports stay open, and prints each new dial error (<resource>: reconnect failed: <error>; retrying), so the balancer can route it to another instance.
- Running TCP connections end; a new one waits up to 10 s for the connection and is closed otherwise.
- UDP opens a new channel (a new session with an empty flow table) on the next datagram.
- A changed host key or a refused key ends the client with an error.
Windows
Section titled “Windows”Releases ship werbot for Windows as a .zip archive. On Windows the client commands (login, ls, ssh, ssh-config, connect, proxy, status, logout) are supported; connect --vnet and the server, gateway and web roles are not.