def construct_ssh_auth_args(self, root_pw=None, pkey=None, pkey_pw=None):
args = {}
if root_pw:
args.update({"password": root_pw})
if pkey:
try:
# private key to match a public key on the server
# optionally encrypted
pkey_filelike = StringIO(pkey)
if pkey_pw:
pkey_paramiko = paramiko.RSAKey.from_private_key(
pkey_filelike,
pkey_pw)
else:
pkey_paramiko = paramiko.RSAKey.from_private_key(pkey_filelike)
args.update({"pkey": pkey_paramiko})
except SSHException:
# Invalid key, or wrong passphase to enc key
# pass on form of auth
pass
return args
评论列表
文章目录