MCPcopy Index your code
hub / github.com/coder/coder / SSHOnPort

Method SSHOnPort

codersdk/workspacesdk/agentconn.go:288–298  ·  view source on GitHub ↗

SSHOnPort pipes the SSH protocol over the returned net.Conn. This connects to the built-in SSH server in the workspace agent on the specified port.

(ctx context.Context, port uint16)

Source from the content-addressed store, hash-verified

286// SSHOnPort pipes the SSH protocol over the returned net.Conn.
287// This connects to the built-in SSH server in the workspace agent on the specified port.
288func (c *agentConn) SSHOnPort(ctx context.Context, port uint16) (*gonet.TCPConn, error) {
289 ctx, span := tracing.StartSpan(ctx)
290 defer span.End()
291
292 if !c.AwaitReachable(ctx) {
293 return nil, xerrors.Errorf("workspace agent not reachable in time: %v", ctx.Err())
294 }
295
296 c.SendConnectedTelemetry(c.agentAddress(), tailnet.TelemetryApplicationSSH)
297 return c.DialContextTCP(ctx, netip.AddrPortFrom(c.agentAddress(), port))
298}
299
300// SSHClient calls SSH to create a client
301func (c *agentConn) SSHClient(ctx context.Context) (*ssh.Client, error) {

Callers 2

SSHMethod · 0.95
SSHClientOnPortMethod · 0.95

Calls 7

AwaitReachableMethod · 0.95
agentAddressMethod · 0.95
StartSpanFunction · 0.92
ErrMethod · 0.80
DialContextTCPMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected