code: func (tc *TeleportClient) connectToProxy(ctx context.Context) (*ProxyClient, error) {
  	var err error
  
  	proxyPrincipal := tc.getProxySSHPrincipal()
  	sshConfig := &ssh.ClientConfig{
  		User:            proxyPrincipal,
  		HostKeyCallback: tc.HostKeyCallback,
  	}
  
  	// helper to create a ProxyClient struct
  	makeProxyClient := func(sshClient *ssh.Client, m ssh.AuthMethod) *ProxyClient {
  		return &ProxyClient{
  			teleportClient:  tc,
  			Client:          sshClient,
  			proxyAddress:    tc.Config.SSHProxyAddr,
  			proxyPrincipal:  proxyPrincipal,
  			hostKeyCallback: sshConfig.HostKeyCallback,
  			authMethod:      m,
  			hostLogin:       tc.Config.HostLogin,
  			siteName:        tc.Config.SiteName,
  			clientAddr:      tc.ClientAddr,
  		}
  	}
  	successMsg := fmt.Sprintf("Successful auth with proxy %v", tc.Config.SSHProxyAddr)
  	// try to authenticate using every non interactive auth method we have:
  	for i, m := range tc.authMethods() {
  		log.Infof("Connecting proxy=%v login='%v' method=%d", tc.Config.SSHProxyAddr, sshConfig.User, i)
  		var sshClient *ssh.Client
  
  		sshConfig.Auth = []ssh.AuthMethod{m}
  		sshClient, err = ssh.Dial("tcp", tc.Config.SSHProxyAddr, sshConfig)
  		if err != nil {
  			return nil, trace.Wrap(err)
  		}
  		log.Infof(successMsg)
  		return makeProxyClient(sshClient, m), nil
  	}
  	// we have exhausted all auth existing auth methods and local login
  	// is disabled in configuration, or the user refused connecting to untrusted hosts
  	if err == nil {
  		err = trace.BadParameter("failed to authenticate with proxy %v", tc.Config.SSHProxyAddr)
  	}
  	return nil, trace.Wrap(err)
  }
docs: // connectToProxy will dial to the proxy server and return a ProxyClient when
  // successful.