mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-06-07 02:16:55 +02:00
leave use of default port to ssh command
to prevent overwriting ports configured in ~/.ssh/config if no port is specified, don't set the port explicitly to 22
This commit is contained in:
parent
9d79bb82c5
commit
d2f751f0d3
@ -40,8 +40,9 @@ def parse_hostport(rhostport):
|
|||||||
|
|
||||||
and returns a tuple (username, password, port, host)
|
and returns a tuple (username, password, port, host)
|
||||||
"""
|
"""
|
||||||
# default port for SSH is TCP port 22
|
# leave use of default port to ssh command to prevent overwriting
|
||||||
port = 22
|
# ports configured in ~/.ssh/config when no port is given
|
||||||
|
port = None
|
||||||
username = None
|
username = None
|
||||||
password = None
|
password = None
|
||||||
host = rhostport
|
host = rhostport
|
||||||
@ -116,6 +117,10 @@ def connect(ssh_cmd, rhostport, python, stderr, options):
|
|||||||
sshl = shlex.split(ssh_cmd)
|
sshl = shlex.split(ssh_cmd)
|
||||||
else:
|
else:
|
||||||
sshl = ['ssh']
|
sshl = ['ssh']
|
||||||
|
if port is not None:
|
||||||
|
portl = ["-p", str(port)]
|
||||||
|
else:
|
||||||
|
portl = []
|
||||||
if python:
|
if python:
|
||||||
pycmd = "'%s' -c '%s'" % (python, pyscript)
|
pycmd = "'%s' -c '%s'" % (python, pyscript)
|
||||||
else:
|
else:
|
||||||
@ -126,12 +131,12 @@ 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 +
|
||||||
["-p", str(port)] +
|
portl +
|
||||||
[rhost, '--', pycmd])
|
[rhost, '--', pycmd])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
argv = (sshl +
|
argv = (sshl +
|
||||||
["-p", str(port)] +
|
portl +
|
||||||
[rhost, '--', pycmd])
|
[rhost, '--', pycmd])
|
||||||
(s1, s2) = socket.socketpair()
|
(s1, s2) = socket.socketpair()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user