summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@gmail.com>2010-05-04 13:07:51 -0400
committerAvery Pennarun <apenwarr@gmail.com>2010-05-04 13:08:38 -0400
commit8173925bcdf87ca2fa9c1942086a4a51436200da (patch)
treeac12ead4356b00ecf45e6d83393b2825fca3a067
parent0cdd72c8304fcb1df86cb884ca63f2bdbfd9a4b0 (diff)
ssh.py: allow hostnames of the form hostname:port
Feature requested by Wayne Scott and Ed Maste.
-rwxr-xr-xmain.py2
-rw-r--r--ssh.py9
2 files changed, 8 insertions, 3 deletions
diff --git a/main.py b/main.py
index e683ca6..9e3b90c 100755
--- a/main.py
+++ b/main.py
@@ -45,7 +45,7 @@ def parse_ipport(s):
optspec = """
-sshuttle [-l [ip:]port] [-r [username@]sshserver] <subnets...>
+sshuttle [-l [ip:]port] [-r [username@]sshserver[:port]] <subnets...>
sshuttle --iptables <port> <subnets...>
sshuttle --server
--
diff --git a/ssh.py b/ssh.py
index a44d2af..3c83e2b 100644
--- a/ssh.py
+++ b/ssh.py
@@ -2,8 +2,13 @@ import sys, os, re, subprocess, socket
import helpers
from helpers import *
-def connect(rhost):
+def connect(rhostport):
main_exe = sys.argv[0]
+ l = (rhostport or '').split(':', 1)
+ rhost = l[0]
+ portl = []
+ if len(l) > 1:
+ portl = ['-p', str(int(l[1]))]
nicedir = os.path.split(os.path.abspath(main_exe))[0]
nicedir = re.sub(r':', "_", nicedir)
myhome = os.path.expanduser('~') + '/'
@@ -29,7 +34,7 @@ def connect(rhost):
sh -c PATH=%s:'$HOME'/%s:'$PATH exec sshuttle --server%s'
""" % (escapedir, escapedir2,
' -v' * (helpers.verbose or 0))
- argv = ['ssh', rhost, '--', cmd.strip()]
+ argv = ['ssh'] + portl + [rhost, '--', cmd.strip()]
debug2('executing: %r\n' % argv)
(s1,s2) = socket.socketpair()
def setup():