Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion asyncssh/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ async def _open_tunnel(tunnels: object, options: _Options,
last_conn = conn
conn = await connect(host, port, username=username,
passphrase=options.passphrase, tunnel=conn,
config=config)
config=config, reload=False)
conn.set_tunnel(last_conn)

if options.canonicalize_hostname != 'always':
Expand Down
50 changes: 50 additions & 0 deletions tests/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,17 @@ def unix_connection_requested(self, dest_path):

return self._upstream_conn

class _JumpServer(Server):
def __init__(self, remote_port):
self._remote_port = remote_port

def begin_auth(self, username):
"""user jumper is allowed to use this server"""
return username != "jumper"

def connection_requested(self, dest_host, dest_port, orig_host, orig_port):
return dest_port == self._remote_port


class _CheckForwarding(ServerTestCase):
"""Utility functions for AsyncSSH forwarding unit tests"""
Expand Down Expand Up @@ -379,6 +390,45 @@ async def test_proxy_jump(self):
finally:
os.remove('.ssh/config')

@asynctest
async def test_proxy_jump_user(self):
"""Test connecting a tunnneled SSH connection using ProxyJump
with a User
"""
import logging
logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
asyncssh.set_log_level('DEBUG')

def jump_server():
return _JumpServer(self._server_port)


jump_listener = await self.create_server(jump_server)
jump_port = jump_listener.get_port()


write_file('.ssh/config',
f"""
Host jump
HostName 127.0.0.3
Port {jump_port}
User jumper
Host target
Hostname 127.0.0.2
Port {self._server_port}
Match final host 127.0.0.2
ProxyJump jump
""".encode())
try:
async with self.connect(host='target', username='ckey'):
pass
finally:
os.remove('.ssh/config')
jump_listener.close()
await jump_listener.wait_closed()

@asynctest
async def test_proxy_jump_multiple(self):
"""Test connecting a tunnneled SSH connection using ProxyJump"""
Expand Down