Skip to content

Commit e4ac4f5

Browse files
authored
add look_for_keys option (#299)
Fix #296.
1 parent a812090 commit e4ac4f5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

dpdispatcher/ssh_context.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def __init__(self,
3232
passphrase=None,
3333
timeout=10,
3434
totp_secret=None,
35-
tar_compress=True
35+
tar_compress=True,
36+
look_for_keys=True,
3637
):
3738

3839
self.hostname = hostname
@@ -45,6 +46,7 @@ def __init__(self,
4546
self.totp_secret = totp_secret
4647
self.ssh = None
4748
self.tar_compress = tar_compress
49+
self.look_for_keys = look_for_keys
4850
self._setup_ssh()
4951

5052
# @classmethod
@@ -160,7 +162,7 @@ def _setup_ssh(self):
160162
pass
161163
if key is not None:
162164
break
163-
else:
165+
elif self.look_for_keys:
164166
for keytype, name in [
165167
(paramiko.RSAKey, "rsa"),
166168
(paramiko.DSSKey, "dsa"),
@@ -298,6 +300,7 @@ def arginfo():
298300
doc_totp_secret = 'Time-based one time password secret. It should be a base32-encoded string' \
299301
' extracted from the 2D code.'
300302
doc_tar_compress = 'The archive will be compressed in upload and download if it is True. If not, compression will be skipped.'
303+
doc_look_for_keys = "enable searching for discoverable private key files in ~/.ssh/"
301304

302305
ssh_remote_profile_args = [
303306
Argument("hostname", str, optional=False, doc=doc_hostname),
@@ -309,6 +312,7 @@ def arginfo():
309312
Argument("timeout", int, optional=True, default=10, doc=doc_timeout),
310313
Argument("totp_secret", str, optional=True, default=None, doc=doc_totp_secret),
311314
Argument("tar_compress", bool, optional=True, default=True, doc = doc_tar_compress),
315+
Argument("look_for_keys", bool, optional=True, default=True, doc=doc_look_for_keys),
312316
]
313317
ssh_remote_profile_format = Argument("ssh_session", dict, ssh_remote_profile_args)
314318
return ssh_remote_profile_format

0 commit comments

Comments
 (0)