diff --git a/README.rst b/README.rst index de3ecbb..f1dafa1 100644 --- a/README.rst +++ b/README.rst @@ -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 -------- diff --git a/rrmngmnt/ssh.py b/rrmngmnt/ssh.py index e860594..cf4329c 100644 --- a/rrmngmnt/ssh.py +++ b/rrmngmnt/ssh.py @@ -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: