Skip to content
Open
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
16 changes: 14 additions & 2 deletions sshtunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,8 @@ def _read_ssh_config(ssh_host,
# Try to read SSH_CONFIG_FILE
try:
# open the ssh config file
with open(os.path.expanduser(ssh_config_file), 'r') as f:
config_path = os.path.expanduser(ssh_config_file)
with open(config_path, 'r') as f:
ssh_config.parse(f)
# looks for information for the destination system
hostname_info = ssh_config.lookup(ssh_host)
Expand All @@ -1021,7 +1022,18 @@ def _read_ssh_config(ssh_host,
ssh_host = hostname_info.get('hostname')
ssh_port = ssh_port or hostname_info.get('port')

proxycommand = hostname_info.get('proxycommand')
proxycommand = hostname_info.get("proxycommand")
if not proxycommand and "proxyjump" in hostname_info:
hops = list(reversed(hostname_info["proxyjump"].split(",")))
if len(hops) > 1:
raise ValueError(
"ProxyJump with more than one proxy server is not supported."
)
# -F forces the continued use of the same SSH config file
proxycommand = "ssh {} -F {} -W {}:{}".format(
hops[0], os.path.abspath(config_path), ssh_host, ssh_port
)

ssh_proxy = ssh_proxy or (paramiko.ProxyCommand(proxycommand) if
proxycommand else None)
if compression is None:
Expand Down