fix: 修复非 ssh 协议的系统用户存在错误私钥,引发的解析问题

pull/9213/head
Eric 2022-12-15 15:17:36 +08:00
parent 8979228e0b
commit f7f9fb1bdf
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