mirror of https://github.com/Xhofe/alist
Co-authored-by: XZB <i@1248.ink>pull/6436/head
parent
453d7da622
commit
227d034db8
|
@ -10,6 +10,7 @@ type Addition struct {
|
|||
Username string `json:"username" required:"true"`
|
||||
PrivateKey string `json:"private_key" type:"text"`
|
||||
Password string `json:"password"`
|
||||
Passphrase string `json:"passphrase"`
|
||||
driver.RootPath
|
||||
IgnoreSymlinkError bool `json:"ignore_symlink_error" default:"false" info:"Ignore symlink error"`
|
||||
}
|
||||
|
|
|
@ -12,8 +12,14 @@ import (
|
|||
|
||||
func (d *SFTP) initClient() error {
|
||||
var auth ssh.AuthMethod
|
||||
if d.PrivateKey != "" {
|
||||
signer, err := ssh.ParsePrivateKey([]byte(d.PrivateKey))
|
||||
if len(d.PrivateKey) > 0 {
|
||||
var err error
|
||||
var signer ssh.Signer
|
||||
if len(d.Passphrase) > 0 {
|
||||
signer, err = ssh.ParsePrivateKeyWithPassphrase([]byte(d.PrivateKey), []byte(d.Passphrase))
|
||||
} else {
|
||||
signer, err = ssh.ParsePrivateKey([]byte(d.PrivateKey))
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue