Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
smallinsky committed Mar 25, 2022
1 parent efd8191 commit 208d111
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions lib/client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2287,28 +2287,6 @@ func (tc *TeleportClient) connectToProxy(ctx context.Context) (*ProxyClient, err
}, nil
}

func makeProxySSHClientWithTLSWrapper(ctx context.Context, tc *TeleportClient, sshConfig *ssh.ClientConfig, proxyAddr string) (*ssh.Client, error) {
cfg := tc.Config
clientTLSConf, err := tc.loadTLSConfig()
if err != nil {
return nil, trace.Wrap(err)
}

clientTLSConf.NextProtos = []string{string(alpncommon.ProtocolProxySSH)}
clientTLSConf.InsecureSkipVerify = cfg.InsecureSkipVerify

tlsConn, err := tls.Dial("tcp", proxyAddr, clientTLSConf)
if err != nil {
return nil, trace.Wrap(err, "failed to dial tls %v", proxyAddr)
}
c, chans, reqs, err := ssh.NewClientConn(tlsConn, proxyAddr, sshConfig)
if err != nil {
// tlsConn is closed inside ssh.NewClientConn function
return nil, trace.Wrap(err, "failed to authenticate with proxy %v", addr)
}
return ssh.NewClient(c, chans, reqs), nil
}

// makeProxySSHClient creates an SSH client by following steps:
// 1) If the current proxy supports TLS Routing and JumpHost address was not provided use TLSWrapper.
// 2) Check JumpHost raw SSH port or Teleport proxy address.
Expand Down Expand Up @@ -2360,6 +2338,17 @@ func makeProxySSHClientDirect(tc *TeleportClient, sshConfig *ssh.ClientConfig) (
return dialer.Dial("tcp", tc.Config.SSHProxyAddr, sshConfig)
}

func makeProxySSHClientWithTLSWrapper(ctx context.Context, tc *TeleportClient, sshConfig *ssh.ClientConfig, proxyAddr string) (*ssh.Client, error) {
tlsConfig, err := tc.loadTLSConfig()
if err != nil {
return nil, trace.Wrap(err)
}

tlsConfig.NextProtos = []string{string(alpncommon.ProtocolProxySSH)}
dialer := proxy.DialerFromEnvironment(tc.Config.WebProxyAddr, proxy.WithALPNDialer(tlsConfig))
return dialer.Dial("tcp", proxyAddr, sshConfig)
}

func (tc *TeleportClient) rootClusterName() (string, error) {
if tc.localAgent == nil {
return "", trace.NotFound("cannot load root cluster name without local agent")
Expand Down

0 comments on commit 208d111

Please sign in to comment.