Exemple #1
0
func NewTunnelledSSHClient(user, tunaddr, tgtaddr string) (*gossh.ClientConn, error) {
	clientConfig, err := sshClientConfig(user)
	if err != nil {
		return nil, err
	}

	var tunnelClient *gossh.ClientConn
	dialFunc := func(echan chan error) {
		var err error
		tunnelClient, err = gossh.Dial("tcp", tunaddr, clientConfig)
		echan <- err
	}
	err = timeoutSSHDial(dialFunc)
	if err != nil {
		return nil, err
	}

	var targetConn net.Conn
	dialFunc = func(echan chan error) {
		var err error
		targetConn, err = tunnelClient.Dial("tcp", tgtaddr)
		echan <- err
	}
	err = timeoutSSHDial(dialFunc)
	if err != nil {
		return nil, err
	}

	targetClient, err := gossh.Client(targetConn, clientConfig)
	if err != nil {
		return nil, err
	}

	return targetClient, nil
}
Exemple #2
0
func NewSSHClient(user, addr string) (*gossh.ClientConn, error) {
	clientConfig, err := sshClientConfig(user)
	if err != nil {
		return nil, err
	}

	var client *gossh.ClientConn
	dialFunc := func(echan chan error) {
		var err error
		client, err = gossh.Dial("tcp", addr, clientConfig)
		echan <- err
	}
	err = timeoutSSHDial(dialFunc)
	return client, err
}
Exemple #3
0
func NewTunnelledSSHClient(user, tunaddr, tgtaddr string) (*gossh.ClientConn, error) {
	clientConfig := sshClientConfig(user)

	tunnelClient, err := gossh.Dial("tcp", tunaddr, clientConfig)
	if err != nil {
		return nil, err
	}

	targetConn, err := tunnelClient.Dial("tcp", tgtaddr)
	if err != nil {
		return nil, err
	}

	targetClient, err := gossh.Client(targetConn, clientConfig)
	if err != nil {
		return nil, err
	}

	return targetClient, nil
}
Exemple #4
0
func NewSSHClient(user, addr string) (*gossh.ClientConn, error) {
	clientConfig := sshClientConfig(user)
	return gossh.Dial("tcp", addr, clientConfig)
}