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

Method SSHClientOnPort

codersdk/workspacesdk/agentconn.go:306–326  ·  view source on GitHub ↗

SSHClientOnPort calls SSH to create a client on a specific port

(ctx context.Context, port uint16)

Source from the content-addressed store, hash-verified

304
305// SSHClientOnPort calls SSH to create a client on a specific port
306func (c *agentConn) SSHClientOnPort(ctx context.Context, port uint16) (*ssh.Client, error) {
307 ctx, span := tracing.StartSpan(ctx)
308 defer span.End()
309
310 netConn, err := c.SSHOnPort(ctx, port)
311 if err != nil {
312 return nil, xerrors.Errorf("ssh: %w", err)
313 }
314
315 sshConn, channels, requests, err := ssh.NewClientConn(netConn, "localhost:22", &ssh.ClientConfig{
316 // SSH host validation isn't helpful, because obtaining a peer
317 // connection already signifies user-intent to dial a workspace.
318 // #nosec
319 HostKeyCallback: ssh.InsecureIgnoreHostKey(),
320 })
321 if err != nil {
322 return nil, xerrors.Errorf("ssh conn: %w", err)
323 }
324
325 return ssh.NewClient(sshConn, channels, requests), nil
326}
327
328// Speedtest runs a speedtest against the workspace agent.
329func (c *agentConn) Speedtest(ctx context.Context, direction speedtest.Direction, duration time.Duration) ([]speedtest.Result, error) {

Callers 1

SSHClientMethod · 0.95

Calls 3

SSHOnPortMethod · 0.95
StartSpanFunction · 0.92
ErrorfMethod · 0.45

Tested by

no test coverage detected