diff options
author | Tony Kasparick <tokas@mailbox.org> | 2020-06-16 23:00:51 +0200 |
---|---|---|
committer | Brian May <brian@linuxpenguins.xyz> | 2020-06-17 08:04:35 +1000 |
commit | d2f751f0d3fdd519c95a0bb8ef18d274e250bf1b (patch) | |
tree | 2de766326444cc8afafbdcfe7a84accbf31ec8dd | |
parent | 9d79bb82c53f75f9bcf362aa214b4230931dfec5 (diff) |
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
-rw-r--r-- | sshuttle/ssh.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sshuttle/ssh.py b/sshuttle/ssh.py index 8d9115d..5ecdec8 100644 --- a/sshuttle/ssh.py +++ b/sshuttle/ssh.py @@ -40,8 +40,9 @@ def parse_hostport(rhostport): and returns a tuple (username, password, port, host) """ - # default port for SSH is TCP port 22 - port = 22 + # leave use of default port to ssh command to prevent overwriting + # ports configured in ~/.ssh/config when no port is given + port = None username = None password = None host = rhostport @@ -116,6 +117,10 @@ def connect(ssh_cmd, rhostport, python, stderr, options): sshl = shlex.split(ssh_cmd) else: sshl = ['ssh'] + if port is not None: + portl = ["-p", str(port)] + else: + portl = [] if python: pycmd = "'%s' -c '%s'" % (python, pyscript) else: @@ -126,12 +131,12 @@ def connect(ssh_cmd, rhostport, python, stderr, options): if password is not None: os.environ['SSHPASS'] = str(password) argv = (["sshpass", "-e"] + sshl + - ["-p", str(port)] + + portl + [rhost, '--', pycmd]) else: argv = (sshl + - ["-p", str(port)] + + portl + [rhost, '--', pycmd]) (s1, s2) = socket.socketpair() |