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))
|
||||
|
||||
|
||||
def _main(listener, fw, remotename, python, seed_hosts, auto_nets):
|
||||
def _main(listener, fw, ssh_cmd, remotename, python, seed_hosts, auto_nets):
|
||||
handlers = []
|
||||
if helpers.verbose >= 1:
|
||||
helpers.logprefix = 'c : '
|
||||
@ -106,7 +106,7 @@ def _main(listener, fw, remotename, python, seed_hosts, auto_nets):
|
||||
helpers.logprefix = 'client: '
|
||||
debug1('connecting to server...\n')
|
||||
try:
|
||||
(serverproc, serversock) = ssh.connect(remotename, python)
|
||||
(serverproc, serversock) = ssh.connect(ssh_cmd, remotename, python)
|
||||
except socket.error, e:
|
||||
if e.errno == errno.EPIPE:
|
||||
raise Fatal("failed to establish ssh session")
|
||||
@ -181,7 +181,7 @@ def _main(listener, fw, remotename, python, seed_hosts, auto_nets):
|
||||
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):
|
||||
debug1('Starting sshuttle proxy.\n')
|
||||
listener = socket.socket()
|
||||
@ -212,6 +212,7 @@ def main(listenip, remotename, python, seed_hosts, auto_nets,
|
||||
fw = FirewallClient(listenip[1], subnets_include, subnets_exclude)
|
||||
|
||||
try:
|
||||
return _main(listener, fw, remotename, python, seed_hosts, auto_nets)
|
||||
return _main(listener, fw, ssh_cmd, remotename,
|
||||
python, seed_hosts, auto_nets)
|
||||
finally:
|
||||
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
|
||||
x,exclude= exclude this subnet (can be used more than once)
|
||||
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)
|
||||
server (internal use only)
|
||||
firewall (internal use only)
|
||||
@ -97,8 +98,9 @@ try:
|
||||
else:
|
||||
sh = None
|
||||
sys.exit(client.main(parse_ipport(opt.listen or '0.0.0.0:0'),
|
||||
opt.ssh_cmd,
|
||||
remotename,
|
||||
(opt.python or "python"),
|
||||
opt.python,
|
||||
sh,
|
||||
opt.auto_nets,
|
||||
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)
|
||||
|
||||
|
||||
def connect(rhostport, python):
|
||||
def connect(ssh_cmd, rhostport, python):
|
||||
main_exe = sys.argv[0]
|
||||
l = (rhostport or '').split(':', 1)
|
||||
rhost = l[0]
|
||||
@ -53,7 +53,13 @@ def connect(rhostport, python):
|
||||
if not rhost:
|
||||
argv = [python, '-c', pyscript]
|
||||
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()
|
||||
def setup():
|
||||
# runs in the child process
|
||||
|
Loading…
Reference in New Issue
Block a user