mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-11-22 16:03:57 +01:00
Add a new --ssh-cmd= option to let you override the ssh command.
Requested by Axel Beckert.
This commit is contained in:
parent
8b7605cc5d
commit
32b4defa9b
@ -98,7 +98,7 @@ class FirewallClient:
|
|||||||
raise Fatal('cleanup: %r returned %d' % (self.argv, rv))
|
raise Fatal('cleanup: %r returned %d' % (self.argv, rv))
|
||||||
|
|
||||||
|
|
||||||
def _main(listener, fw, remotename, python, seed_hosts, auto_nets):
|
def _main(listener, fw, ssh_cmd, remotename, python, seed_hosts, auto_nets):
|
||||||
handlers = []
|
handlers = []
|
||||||
if helpers.verbose >= 1:
|
if helpers.verbose >= 1:
|
||||||
helpers.logprefix = 'c : '
|
helpers.logprefix = 'c : '
|
||||||
@ -106,7 +106,7 @@ def _main(listener, fw, remotename, python, seed_hosts, auto_nets):
|
|||||||
helpers.logprefix = 'client: '
|
helpers.logprefix = 'client: '
|
||||||
debug1('connecting to server...\n')
|
debug1('connecting to server...\n')
|
||||||
try:
|
try:
|
||||||
(serverproc, serversock) = ssh.connect(remotename, python)
|
(serverproc, serversock) = ssh.connect(ssh_cmd, remotename, python)
|
||||||
except socket.error, e:
|
except socket.error, e:
|
||||||
if e.errno == errno.EPIPE:
|
if e.errno == errno.EPIPE:
|
||||||
raise Fatal("failed to establish ssh session")
|
raise Fatal("failed to establish ssh session")
|
||||||
@ -181,7 +181,7 @@ def _main(listener, fw, remotename, python, seed_hosts, auto_nets):
|
|||||||
mux.check_fullness()
|
mux.check_fullness()
|
||||||
|
|
||||||
|
|
||||||
def main(listenip, remotename, python, seed_hosts, auto_nets,
|
def main(listenip, ssh_cmd, remotename, python, seed_hosts, auto_nets,
|
||||||
subnets_include, subnets_exclude):
|
subnets_include, subnets_exclude):
|
||||||
debug1('Starting sshuttle proxy.\n')
|
debug1('Starting sshuttle proxy.\n')
|
||||||
listener = socket.socket()
|
listener = socket.socket()
|
||||||
@ -212,6 +212,7 @@ def main(listenip, remotename, python, seed_hosts, auto_nets,
|
|||||||
fw = FirewallClient(listenip[1], subnets_include, subnets_exclude)
|
fw = FirewallClient(listenip[1], subnets_include, subnets_exclude)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return _main(listener, fw, remotename, python, seed_hosts, auto_nets)
|
return _main(listener, fw, ssh_cmd, remotename,
|
||||||
|
python, seed_hosts, auto_nets)
|
||||||
finally:
|
finally:
|
||||||
fw.done()
|
fw.done()
|
||||||
|
4
main.py
4
main.py
@ -56,6 +56,7 @@ python= specify the name/path of the python interpreter on the remote server [py
|
|||||||
r,remote= ssh hostname (and optional username) of remote sshuttle server
|
r,remote= ssh hostname (and optional username) of remote sshuttle server
|
||||||
x,exclude= exclude this subnet (can be used more than once)
|
x,exclude= exclude this subnet (can be used more than once)
|
||||||
v,verbose increase debug message verbosity
|
v,verbose increase debug message verbosity
|
||||||
|
e,ssh-cmd= the command to use to connect to the remote [ssh]
|
||||||
seed-hosts= with -H, use these hostnames for initial scan (comma-separated)
|
seed-hosts= with -H, use these hostnames for initial scan (comma-separated)
|
||||||
server (internal use only)
|
server (internal use only)
|
||||||
firewall (internal use only)
|
firewall (internal use only)
|
||||||
@ -97,8 +98,9 @@ try:
|
|||||||
else:
|
else:
|
||||||
sh = None
|
sh = None
|
||||||
sys.exit(client.main(parse_ipport(opt.listen or '0.0.0.0:0'),
|
sys.exit(client.main(parse_ipport(opt.listen or '0.0.0.0:0'),
|
||||||
|
opt.ssh_cmd,
|
||||||
remotename,
|
remotename,
|
||||||
(opt.python or "python"),
|
opt.python,
|
||||||
sh,
|
sh,
|
||||||
opt.auto_nets,
|
opt.auto_nets,
|
||||||
parse_subnets(includes),
|
parse_subnets(includes),
|
||||||
|
10
ssh.py
10
ssh.py
@ -21,7 +21,7 @@ def empackage(z, filename):
|
|||||||
return '%s\n%d\n%s' % (basename,len(content), content)
|
return '%s\n%d\n%s' % (basename,len(content), content)
|
||||||
|
|
||||||
|
|
||||||
def connect(rhostport, python):
|
def connect(ssh_cmd, rhostport, python):
|
||||||
main_exe = sys.argv[0]
|
main_exe = sys.argv[0]
|
||||||
l = (rhostport or '').split(':', 1)
|
l = (rhostport or '').split(':', 1)
|
||||||
rhost = l[0]
|
rhost = l[0]
|
||||||
@ -53,7 +53,13 @@ def connect(rhostport, python):
|
|||||||
if not rhost:
|
if not rhost:
|
||||||
argv = [python, '-c', pyscript]
|
argv = [python, '-c', pyscript]
|
||||||
else:
|
else:
|
||||||
argv = ['ssh'] + portl + [rhost, '--', "'%s' -c '%s'" % (python, pyscript)]
|
if ssh_cmd:
|
||||||
|
sshl = ssh_cmd.split(' ')
|
||||||
|
else:
|
||||||
|
sshl = ['ssh']
|
||||||
|
argv = (sshl +
|
||||||
|
portl +
|
||||||
|
[rhost, '--', "'%s' -c '%s'" % (python, pyscript)])
|
||||||
(s1,s2) = socket.socketpair()
|
(s1,s2) = socket.socketpair()
|
||||||
def setup():
|
def setup():
|
||||||
# runs in the child process
|
# runs in the child process
|
||||||
|
Loading…
Reference in New Issue
Block a user