mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-04-24 03:08:56 +02:00
Add support for non-compliant ssh wrappers
ssh wrappers like teleport's tsh do not correctly interpret the double dash as an argument delimiter and will not work properly with sshuttle. This PR adds a new command line switch to handle these cases by not adding the delimiter. Fixes #599
This commit is contained in:
parent
6cdae8c3e5
commit
348f0eb653
@ -181,6 +181,13 @@ Options
|
|||||||
in a non-standard location or you want to provide extra
|
in a non-standard location or you want to provide extra
|
||||||
options to the ssh command, for example, ``-e 'ssh -v'``.
|
options to the ssh command, for example, ``-e 'ssh -v'``.
|
||||||
|
|
||||||
|
.. option:: --no-cmd-delimiter
|
||||||
|
|
||||||
|
Do not add a double dash (--) delimiter before invoking Python on
|
||||||
|
the remote host. This option is useful when the ssh command used
|
||||||
|
to connect is a custom command that does not interpret this
|
||||||
|
delimiter correctly.
|
||||||
|
|
||||||
.. option:: --seed-hosts
|
.. option:: --seed-hosts
|
||||||
|
|
||||||
A comma-separated list of hostnames to use to
|
A comma-separated list of hostnames to use to
|
||||||
|
@ -539,7 +539,7 @@ def ondns(listener, method, mux, handlers):
|
|||||||
def _main(tcp_listener, udp_listener, fw, ssh_cmd, remotename,
|
def _main(tcp_listener, udp_listener, fw, ssh_cmd, remotename,
|
||||||
python, latency_control, latency_buffer_size,
|
python, latency_control, latency_buffer_size,
|
||||||
dns_listener, seed_hosts, auto_hosts, auto_nets, daemon,
|
dns_listener, seed_hosts, auto_hosts, auto_nets, daemon,
|
||||||
to_nameserver):
|
to_nameserver, add_cmd_delimiter):
|
||||||
|
|
||||||
helpers.logprefix = 'c : '
|
helpers.logprefix = 'c : '
|
||||||
debug1('Starting client with Python version %s'
|
debug1('Starting client with Python version %s'
|
||||||
@ -554,6 +554,7 @@ def _main(tcp_listener, udp_listener, fw, ssh_cmd, remotename,
|
|||||||
(serverproc, serversock) = ssh.connect(
|
(serverproc, serversock) = ssh.connect(
|
||||||
ssh_cmd, remotename, python,
|
ssh_cmd, remotename, python,
|
||||||
stderr=ssyslog._p and ssyslog._p.stdin,
|
stderr=ssyslog._p and ssyslog._p.stdin,
|
||||||
|
add_cmd_delimiter=add_cmd_delimiter,
|
||||||
options=dict(latency_control=latency_control,
|
options=dict(latency_control=latency_control,
|
||||||
latency_buffer_size=latency_buffer_size,
|
latency_buffer_size=latency_buffer_size,
|
||||||
auto_hosts=auto_hosts,
|
auto_hosts=auto_hosts,
|
||||||
@ -755,7 +756,7 @@ def main(listenip_v6, listenip_v4,
|
|||||||
latency_buffer_size, dns, nslist,
|
latency_buffer_size, dns, nslist,
|
||||||
method_name, seed_hosts, auto_hosts, auto_nets,
|
method_name, seed_hosts, auto_hosts, auto_nets,
|
||||||
subnets_include, subnets_exclude, daemon, to_nameserver, pidfile,
|
subnets_include, subnets_exclude, daemon, to_nameserver, pidfile,
|
||||||
user, group, sudo_pythonpath, tmark):
|
user, group, sudo_pythonpath, add_cmd_delimiter, tmark):
|
||||||
|
|
||||||
if not remotename:
|
if not remotename:
|
||||||
raise Fatal("You must use -r/--remote to specify a remote "
|
raise Fatal("You must use -r/--remote to specify a remote "
|
||||||
@ -1103,7 +1104,7 @@ def main(listenip_v6, listenip_v4,
|
|||||||
return _main(tcp_listener, udp_listener, fw, ssh_cmd, remotename,
|
return _main(tcp_listener, udp_listener, fw, ssh_cmd, remotename,
|
||||||
python, latency_control, latency_buffer_size,
|
python, latency_control, latency_buffer_size,
|
||||||
dns_listener, seed_hosts, auto_hosts, auto_nets,
|
dns_listener, seed_hosts, auto_hosts, auto_nets,
|
||||||
daemon, to_nameserver)
|
daemon, to_nameserver, add_cmd_delimiter)
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
if daemon:
|
if daemon:
|
||||||
|
@ -115,6 +115,7 @@ def main():
|
|||||||
opt.user,
|
opt.user,
|
||||||
opt.group,
|
opt.group,
|
||||||
opt.sudo_pythonpath,
|
opt.sudo_pythonpath,
|
||||||
|
opt.add_cmd_delimiter,
|
||||||
opt.tmark)
|
opt.tmark)
|
||||||
|
|
||||||
if return_code == 0:
|
if return_code == 0:
|
||||||
|
@ -301,6 +301,14 @@ parser.add_argument(
|
|||||||
the command to use to connect to the remote [%(default)s]
|
the command to use to connect to the remote [%(default)s]
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--no-cmd-delimiter",
|
||||||
|
action="store_false",
|
||||||
|
dest="add_cmd_delimiter",
|
||||||
|
help="""
|
||||||
|
do not add a double dash before the python command
|
||||||
|
"""
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--seed-hosts",
|
"--seed-hosts",
|
||||||
metavar="HOSTNAME[,HOSTNAME]",
|
metavar="HOSTNAME[,HOSTNAME]",
|
||||||
|
@ -84,7 +84,7 @@ def parse_hostport(rhostport):
|
|||||||
return username, password, port, host
|
return username, password, port, host
|
||||||
|
|
||||||
|
|
||||||
def connect(ssh_cmd, rhostport, python, stderr, options):
|
def connect(ssh_cmd, rhostport, python, stderr, add_cmd_delimiter, options):
|
||||||
username, password, port, host = parse_hostport(rhostport)
|
username, password, port, host = parse_hostport(rhostport)
|
||||||
if username:
|
if username:
|
||||||
rhost = "{}@{}".format(username, host)
|
rhost = "{}@{}".format(username, host)
|
||||||
@ -183,13 +183,15 @@ def connect(ssh_cmd, rhostport, python, stderr, options):
|
|||||||
if password is not None:
|
if password is not None:
|
||||||
os.environ['SSHPASS'] = str(password)
|
os.environ['SSHPASS'] = str(password)
|
||||||
argv = (["sshpass", "-e"] + sshl +
|
argv = (["sshpass", "-e"] + sshl +
|
||||||
portl +
|
portl + [rhost])
|
||||||
[rhost, '--', pycmd])
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
argv = (sshl +
|
argv = (sshl + portl + [rhost])
|
||||||
portl +
|
|
||||||
[rhost, '--', pycmd])
|
if add_cmd_delimiter:
|
||||||
|
argv += ['--', pycmd]
|
||||||
|
else:
|
||||||
|
argv += [pycmd]
|
||||||
|
|
||||||
# Our which() function searches for programs in get_path()
|
# Our which() function searches for programs in get_path()
|
||||||
# directories (which include PATH). This step isn't strictly
|
# directories (which include PATH). This step isn't strictly
|
||||||
|
Loading…
Reference in New Issue
Block a user