fix(sftp-server): postgre cannot store control characters (#8188 close #8186)

This commit is contained in:
KirCute
2025-03-27 23:14:36 +08:00
committed by GitHub
parent 32890da29f
commit 6e13923225
3 changed files with 10 additions and 6 deletions

View File

@ -113,11 +113,15 @@ func (d *SftpDriver) PublicKeyAuth(conn ssh.ConnMetadata, key ssh.PublicKey) (*s
}
marshal := string(key.Marshal())
for _, sk := range keys {
if marshal == sk.KeyStr {
sk.LastUsedTime = time.Now()
_ = op.UpdateSSHPublicKey(&sk)
return nil, nil
if marshal != sk.KeyStr {
pubKey, _, _, _, e := ssh.ParseAuthorizedKey([]byte(sk.KeyStr))
if e != nil || marshal != string(pubKey.Marshal()) {
continue
}
}
sk.LastUsedTime = time.Now()
_ = op.UpdateSSHPublicKey(&sk)
return nil, nil
}
return nil, errors.New("public key refused")
}