예제 #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
}
예제 #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
}
예제 #3
0
파일: ssh.go 프로젝트: natacado/fleet
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
}
예제 #4
0
파일: ssh.go 프로젝트: natacado/fleet
func NewSSHClient(user, addr string) (*gossh.ClientConn, error) {
	clientConfig := sshClientConfig(user)
	return gossh.Dial("tcp", addr, clientConfig)
}