Skip to content

Commit

Permalink
Enable to set ssh key from os enviroment (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
myakove authored Mar 20, 2020
1 parent b6ccb63 commit 2914855
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ that means SSH server must be running there already.
h = Host("10.11.12.13")
h.users.append(RootUser('123456'))
# Use with ssh key. export HOST_SSH_KEY to use specific ssh key, default is ~/.ssh/id_rsa
host.executor_factory = rrmngmnt.ssh.RemoteExecutorFactory(use_pkey=True)
exec = h.executor()
print exec.run_cmd(['echo', 'Hello World'])
Features
--------

Expand Down
4 changes: 3 additions & 1 deletion rrmngmnt/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ def __init__(self, executor, timeout=None):
self._ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
if self._executor.use_pkey:
self.pkey = paramiko.RSAKey.from_private_key_file(
ID_RSA_PRV % os.path.expanduser('~')
os.getenv(
"HOST_SSH_KEY", ID_RSA_PRV % os.path.expanduser('~')
)
)
self._executor.user.password = None
else:
Expand Down

0 comments on commit 2914855

Please sign in to comment.