SSHClientOnPort calls SSH to create a client on a specific port
(ctx context.Context, port uint16)
| 304 | |
| 305 | // SSHClientOnPort calls SSH to create a client on a specific port |
| 306 | func (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. |
| 329 | func (c *agentConn) Speedtest(ctx context.Context, direction speedtest.Direction, duration time.Duration) ([]speedtest.Result, error) { |