diff --git a/spur/ssh.py b/spur/ssh.py index 24e4a03..22d19ac 100644 --- a/spur/ssh.py +++ b/spur/ssh.py @@ -178,6 +178,7 @@ def spawn(self, command, *args, **kwargs): channel = self._get_ssh_transport().open_session() except EOFError as error: raise self._connection_error(error) + paramiko.agent.AgentRequestHandler(channel) if use_pty: channel.get_pty() channel.exec_command(command_in_cwd) diff --git a/tests/ssh_tests.py b/tests/ssh_tests.py index a239434..5ffca19 100644 --- a/tests/ssh_tests.py +++ b/tests/ssh_tests.py @@ -95,6 +95,13 @@ def an_open_socket_can_be_used_for_ssh_connection_with_sock_argument(): assert_equal(b"hello\n", result.output) +@istest +def ssh_agent_key_forwarding_successful(): + with create_ssh_shell(missing_host_key=spur.ssh.MissingHostKey.accept) as shell: + auth_sock = shell.run(["printenv", "SSH_AUTH_SOCK"]) + assert auth_sock is not None + + def _create_shell_with_wrong_port(**kwargs): return spur.SshShell( username=USERNAME,