|
|
@ -41,16 +41,19 @@ def open_rm_inputs(*, address, key, password): |
|
|
|
agent = paramiko.agent.Agent() |
|
|
|
agent = paramiko.agent.Agent() |
|
|
|
|
|
|
|
|
|
|
|
def use_key(key): |
|
|
|
def use_key(key): |
|
|
|
try: |
|
|
|
for key_type in [paramiko.RSAKey, paramiko.Ed25519Key, paramiko.ECDSAKey]: |
|
|
|
pkey = paramiko.RSAKey.from_private_key_file(os.path.expanduser(key)) |
|
|
|
try: |
|
|
|
except paramiko.ssh_exception.PasswordRequiredException: |
|
|
|
pkey = key_type.from_private_key_file(os.path.expanduser(key)) |
|
|
|
passphrase = getpass( |
|
|
|
except paramiko.ssh_exception.SSHException: |
|
|
|
"Enter passphrase for key '{}': ".format(os.path.expanduser(key)) |
|
|
|
continue |
|
|
|
) |
|
|
|
except paramiko.ssh_exception.PasswordRequiredException: |
|
|
|
pkey = paramiko.RSAKey.from_private_key_file( |
|
|
|
passphrase = getpass( |
|
|
|
os.path.expanduser(key), |
|
|
|
"Enter passphrase for key '{}': ".format(os.path.expanduser(key)) |
|
|
|
password=passphrase |
|
|
|
) |
|
|
|
) |
|
|
|
pkey = paramiko.RSAKey.from_private_key_file( |
|
|
|
|
|
|
|
os.path.expanduser(key), password=passphrase |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
break |
|
|
|
return pkey |
|
|
|
return pkey |
|
|
|
|
|
|
|
|
|
|
|
if key is not None: |
|
|
|
if key is not None: |
|
|
|