def ssh(self, path_info): host, user, port = path_info.host, path_info.user, path_info.port # NOTE: we use the same password regardless of the server :( if self.ask_password and self.password is None: with saved_passwords_lock: server_key = (host, user, port) password = saved_passwords.get(server_key) if password is None: saved_passwords[server_key] = password = prompt.password( "Enter a private key passphrase or a password for " "host '{host}' port '{port}' user '{user}'".format( host=host, port=port, user=user)) self.password = password return get_connection( SSHConnection, host, username=user, port=port, key_filename=self.keyfile, timeout=self.timeout, password=self.password, )
def test_doesnt_swallow_errors(ssh_server): class MyError(Exception): pass with pytest.raises(MyError), get_connection(SSHConnection, **ssh_server.test_creds): raise MyError
def test_doesnt_swallow_errors(ssh_server): class MyError(Exception): pass with pytest.raises(MyError): with get_connection( SSHConnection, host=ssh_server.host, port=ssh_server.port, username=TEST_SSH_USER, key_filename=TEST_SSH_KEY_PATH, ): raise MyError
def ssh(self, path_info): self.ensure_credentials(path_info) from .connection import SSHConnection return get_connection( SSHConnection, path_info.host, username=path_info.user, port=path_info.port, key_filename=self.keyfile, timeout=self.timeout, password=self.password, gss_auth=self.gss_auth, )
def ssh(self, path_info): host, user, port = path_info.host, path_info.user, path_info.port # NOTE: we use the same password regardless of the server :( if self.ask_password and not self.password: self.password = prompt.password( "Enter a private key passphrase or a password for " "host '{host}' port '{port}' user '{user}'".format(host=host, port=port, user=user)) return get_connection( SSHConnection, host, username=user, port=port, key_filename=self.keyfile, timeout=self.timeout, password=self.password, )