Merge pull request #9213 from jumpserver/pr@v2.28@perf_fingerprint

fix: 修复非 ssh 协议的系统用户存在错误私钥,引发的解析问题
pull/9230/head
老广 2022-12-15 15:25:40 +08:00 committed by GitHub
commit 67e334bf43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -63,6 +63,7 @@ class AuthMixin:
@property
def ssh_key_fingerprint(self):
public_key = None
if self.public_key:
public_key = self.public_key
elif self.private_key:
@ -70,9 +71,8 @@ class AuthMixin:
public_key = parse_ssh_public_key_str(self.private_key, password=self.password)
except IOError as e:
return str(e)
else:
if not public_key:
return ''
public_key_obj = sshpubkeys.SSHKey(public_key)
fingerprint = public_key_obj.hash_md5()
return fingerprint