本文整理匯總了Golang中github.com/docker/machine/libmachine/drivers.Driver.GetSSHUsername方法的典型用法代碼示例。如果您正苦於以下問題:Golang Driver.GetSSHUsername方法的具體用法?Golang Driver.GetSSHUsername怎麽用?Golang Driver.GetSSHUsername使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/docker/machine/libmachine/drivers.Driver
的用法示例。
在下文中一共展示了Driver.GetSSHUsername方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newSSHHost
func newSSHHost(d drivers.Driver) (*sshHost, error) {
ip, err := d.GetSSHHostname()
if err != nil {
return nil, errors.Wrap(err, "Error getting ssh host name for driver")
}
port, err := d.GetSSHPort()
if err != nil {
return nil, errors.Wrap(err, "Error getting ssh port for driver")
}
return &sshHost{
IP: ip,
Port: port,
SSHKeyPath: d.GetSSHKeyPath(),
Username: d.GetSSHUsername(),
}, nil
}
示例2: newSSHHost
func newSSHHost(d drivers.Driver) (*sshHost, error) {
ip, err := d.GetSSHHostname()
if err != nil {
return nil, err
}
port, err := d.GetSSHPort()
if err != nil {
return nil, err
}
return &sshHost{
IP: ip,
Port: port,
SSHKeyPath: d.GetSSHKeyPath(),
Username: d.GetSSHUsername(),
}, nil
}
示例3: CreateSSHClient
func (creator *StandardSSHClientCreator) CreateSSHClient(d drivers.Driver) (ssh.Client, error) {
addr, err := d.GetSSHHostname()
if err != nil {
return ssh.ExternalClient{}, err
}
port, err := d.GetSSHPort()
if err != nil {
return ssh.ExternalClient{}, err
}
auth := &ssh.Auth{}
if d.GetSSHKeyPath() != "" {
auth.Keys = []string{d.GetSSHKeyPath()}
}
return ssh.NewClient(d.GetSSHUsername(), addr, port, auth)
}