fix: SSH对象序列化属性值不匹配
This commit is contained in:
@@ -18,8 +18,8 @@ type ConnSSH struct {
|
||||
Port int `json:"port"` // SSH端口
|
||||
AuthMode string `json:"authMode"` // 认证模式(0密码 1主机私钥)
|
||||
Password string `json:"password"` // 认证密码
|
||||
PrivateKey []byte `json:"privateKey"` // 认证私钥
|
||||
PassPhrase []byte `json:"passPhrase"` // 认证私钥密码
|
||||
PrivateKey string `json:"privateKey"` // 认证私钥
|
||||
PassPhrase string `json:"passPhrase"` // 认证私钥密码
|
||||
|
||||
DialTimeOut time.Duration `json:"dialTimeOut"` // 连接超时断开
|
||||
|
||||
@@ -54,9 +54,9 @@ func (c *ConnSSH) NewClient() (*ConnSSH, error) {
|
||||
var signer gossh.Signer
|
||||
var err error
|
||||
if len(c.PassPhrase) != 0 {
|
||||
signer, err = gossh.ParsePrivateKeyWithPassphrase(c.PrivateKey, c.PassPhrase)
|
||||
signer, err = gossh.ParsePrivateKeyWithPassphrase([]byte(c.PrivateKey), []byte(c.PassPhrase))
|
||||
} else {
|
||||
signer, err = gossh.ParsePrivateKey(c.PrivateKey)
|
||||
signer, err = gossh.ParsePrivateKey([]byte(c.PrivateKey))
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user