mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-07-04 16:50:34 +02:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
c5dcc918db | |||
329b9cd0a0 | |||
5537a90338 | |||
636e0442e5 | |||
dc526747b1 | |||
73eb3b6479 | |||
1b50d364c6 | |||
8c91958ff3 | |||
d2f751f0d3 | |||
9d79bb82c5 | |||
a53f026056 | |||
ae4c7e3a7b | |||
61bbbca956 | |||
e56f8f2349 | |||
0a36eac686 | |||
16b462880b | |||
500aa65693 | |||
7d998f6d42 |
21
CHANGES.rst
21
CHANGES.rst
@ -9,6 +9,27 @@ adheres to `Semantic Versioning`_.
|
|||||||
.. _`Semantic Versioning`: http://semver.org/
|
.. _`Semantic Versioning`: http://semver.org/
|
||||||
|
|
||||||
|
|
||||||
|
1.0.3 - 2020-07-12
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Fixed
|
||||||
|
~~~~~
|
||||||
|
* Ask setuptools to require Python 3.5 and above.
|
||||||
|
* Add missing import.
|
||||||
|
* Fix formatting typos in usage docs
|
||||||
|
|
||||||
|
|
||||||
|
1.0.2 - 2020-06-18
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Fixed
|
||||||
|
~~~~~
|
||||||
|
* Leave use of default port to ssh command.
|
||||||
|
* Remove unwanted references to Python 2.7 in docs.
|
||||||
|
* Replace usage of deprecated imp.
|
||||||
|
* Fix connection with @ sign in username.
|
||||||
|
|
||||||
|
|
||||||
1.0.1 - 2020-06-05
|
1.0.1 - 2020-06-05
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ Description
|
|||||||
-----------
|
-----------
|
||||||
:program:`sshuttle` allows you to create a VPN connection from your
|
:program:`sshuttle` allows you to create a VPN connection from your
|
||||||
machine to any remote server that you can connect to via
|
machine to any remote server that you can connect to via
|
||||||
ssh, as long as that server has python 2.3 or higher.
|
ssh, as long as that server has python 3.5 or higher.
|
||||||
|
|
||||||
To work, you must have root access on the local machine,
|
To work, you must have root access on the local machine,
|
||||||
but you can have a normal account on the server.
|
but you can have a normal account on the server.
|
||||||
|
@ -57,9 +57,8 @@ cmd.exe with Administrator access. See :doc:`windows` for more information.
|
|||||||
|
|
||||||
Server side Requirements
|
Server side Requirements
|
||||||
------------------------
|
------------------------
|
||||||
The server can run in any version of Python between 2.4 and 3.6.
|
|
||||||
However it is recommended that you use Python 2.7, Python 3.5 or later whenever
|
- Python 3.5 or greater.
|
||||||
possible as support for older versions might be dropped in the future.
|
|
||||||
|
|
||||||
|
|
||||||
Additional Suggested Software
|
Additional Suggested Software
|
||||||
|
@ -21,7 +21,7 @@ Forward all traffic::
|
|||||||
sshuttle -r username@sshserver 0/0
|
sshuttle -r username@sshserver 0/0
|
||||||
|
|
||||||
|
|
||||||
- For 'My VPN broke and need a temporary solution FAST to access local IPv4 addresses':
|
- For 'My VPN broke and need a temporary solution FAST to access local IPv4 addresses'::
|
||||||
|
|
||||||
sshuttle --dns -NHr username@sshserver 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
|
sshuttle --dns -NHr username@sshserver 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ Sudoers File
|
|||||||
sshuttle can auto-generate the proper sudoers.d file using the current user
|
sshuttle can auto-generate the proper sudoers.d file using the current user
|
||||||
for Linux and OSX. Doing this will allow sshuttle to run without asking for
|
for Linux and OSX. Doing this will allow sshuttle to run without asking for
|
||||||
the local sudo password and to give users who do not have sudo access
|
the local sudo password and to give users who do not have sudo access
|
||||||
ability to run sshuttle.
|
ability to run sshuttle::
|
||||||
|
|
||||||
sshuttle --sudoers
|
sshuttle --sudoers
|
||||||
|
|
||||||
@ -82,14 +82,14 @@ option:`sshuttle --sudoers --sudoers-username {user_descriptor}` option. Valid
|
|||||||
values for this vary based on how your system is configured. Values such as
|
values for this vary based on how your system is configured. Values such as
|
||||||
usernames, groups pre-pended with `%` and sudoers user aliases will work. See
|
usernames, groups pre-pended with `%` and sudoers user aliases will work. See
|
||||||
the sudoers manual for more information on valid user specif actions.
|
the sudoers manual for more information on valid user specif actions.
|
||||||
The options must be used with `--sudoers`
|
The options must be used with `--sudoers`::
|
||||||
|
|
||||||
sshuttle --sudoers --sudoers-user mike
|
sshuttle --sudoers --sudoers-user mike
|
||||||
sshuttle --sudoers --sudoers-user %sudo
|
sshuttle --sudoers --sudoers-user %sudo
|
||||||
|
|
||||||
The name of the file to be added to sudoers.d can be configured as well. This
|
The name of the file to be added to sudoers.d can be configured as well. This
|
||||||
is mostly not necessary but can be useful for giving more than one user
|
is mostly not necessary but can be useful for giving more than one user
|
||||||
access to sshuttle. The default is `sshuttle_auto`
|
access to sshuttle. The default is `sshuttle_auto`::
|
||||||
|
|
||||||
sshuttle --sudoer --sudoers-filename sshuttle_auto_mike
|
sshuttle --sudoer --sudoers-filename sshuttle_auto_mike
|
||||||
sshuttle --sudoer --sudoers-filename sshuttle_auto_tommy
|
sshuttle --sudoer --sudoers-filename sshuttle_auto_tommy
|
||||||
@ -97,11 +97,11 @@ access to sshuttle. The default is `sshuttle_auto`
|
|||||||
You can also see what configuration will be added to your system without
|
You can also see what configuration will be added to your system without
|
||||||
modifying anything. This can be helpfull is the auto feature does not work, or
|
modifying anything. This can be helpfull is the auto feature does not work, or
|
||||||
you want more control. This option also works with `--sudoers-username`.
|
you want more control. This option also works with `--sudoers-username`.
|
||||||
`--sudoers-filename` has no effect with this option.
|
`--sudoers-filename` has no effect with this option::
|
||||||
|
|
||||||
sshuttle --sudoers-no-modify
|
sshuttle --sudoers-no-modify
|
||||||
|
|
||||||
This will simply sprint the generated configuration to STDOUT. Example
|
This will simply sprint the generated configuration to STDOUT. Example::
|
||||||
|
|
||||||
08:40 PM william$ sshuttle --sudoers-no-modify
|
08:40 PM william$ sshuttle --sudoers-no-modify
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
-r requirements.txt
|
-r requirements.txt
|
||||||
attrs==19.3.0
|
attrs==19.3.0
|
||||||
pytest==5.4.3
|
pytest==5.4.3
|
||||||
pytest-cov==2.9.0
|
pytest-cov==2.10.0
|
||||||
mock==2.0.0
|
mock==2.0.0
|
||||||
flake8==3.8.2
|
flake8==3.8.3
|
||||||
pyflakes==2.2.0
|
pyflakes==2.2.0
|
||||||
|
1
setup.py
1
setup.py
@ -61,6 +61,7 @@ setup(
|
|||||||
'sshuttle = sshuttle.cmdline:main',
|
'sshuttle = sshuttle.cmdline:main',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
python_requires='>=3.5',
|
||||||
tests_require=[
|
tests_require=[
|
||||||
'pytest',
|
'pytest',
|
||||||
'pytest-cov',
|
'pytest-cov',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import sys
|
import sys
|
||||||
import zlib
|
import zlib
|
||||||
import imp
|
import types
|
||||||
|
|
||||||
verbosity = verbosity # noqa: F821 must be a previously defined global
|
verbosity = verbosity # noqa: F821 must be a previously defined global
|
||||||
z = zlib.decompressobj()
|
z = zlib.decompressobj()
|
||||||
@ -15,7 +15,7 @@ while 1:
|
|||||||
% (name, nbytes))
|
% (name, nbytes))
|
||||||
content = z.decompress(sys.stdin.read(nbytes))
|
content = z.decompress(sys.stdin.read(nbytes))
|
||||||
|
|
||||||
module = imp.new_module(name)
|
module = types.ModuleType(name)
|
||||||
parents = name.rsplit(".", 1)
|
parents = name.rsplit(".", 1)
|
||||||
if len(parents) == 2:
|
if len(parents) == 2:
|
||||||
parent, parent_name = parents
|
parent, parent_name = parents
|
||||||
|
@ -3,7 +3,8 @@ import os
|
|||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
import zlib
|
import zlib
|
||||||
import imp
|
import importlib
|
||||||
|
import importlib.util
|
||||||
import subprocess as ssubprocess
|
import subprocess as ssubprocess
|
||||||
import shlex
|
import shlex
|
||||||
from shlex import quote
|
from shlex import quote
|
||||||
@ -14,43 +15,15 @@ import sshuttle.helpers as helpers
|
|||||||
from sshuttle.helpers import debug2
|
from sshuttle.helpers import debug2
|
||||||
|
|
||||||
|
|
||||||
def readfile(name):
|
def get_module_source(name):
|
||||||
tokens = name.split(".")
|
spec = importlib.util.find_spec(name)
|
||||||
f = None
|
with open(spec.origin, "rt") as f:
|
||||||
|
return f.read().encode("utf-8")
|
||||||
token = tokens[0]
|
|
||||||
token_name = [token]
|
|
||||||
token_str = ".".join(token_name)
|
|
||||||
|
|
||||||
try:
|
|
||||||
f, pathname, description = imp.find_module(token_str)
|
|
||||||
|
|
||||||
for token in tokens[1:]:
|
|
||||||
module = imp.load_module(token_str, f, pathname, description)
|
|
||||||
if f is not None:
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
token_name.append(token)
|
|
||||||
token_str = ".".join(token_name)
|
|
||||||
|
|
||||||
f, pathname, description = imp.find_module(
|
|
||||||
token, module.__path__)
|
|
||||||
|
|
||||||
if f is not None:
|
|
||||||
contents = f.read()
|
|
||||||
else:
|
|
||||||
contents = ""
|
|
||||||
|
|
||||||
finally:
|
|
||||||
if f is not None:
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
return contents.encode("UTF8")
|
|
||||||
|
|
||||||
|
|
||||||
def empackage(z, name, data=None):
|
def empackage(z, name, data=None):
|
||||||
if not data:
|
if not data:
|
||||||
data = readfile(name)
|
data = get_module_source(name)
|
||||||
content = z.compress(data)
|
content = z.compress(data)
|
||||||
content += z.flush(zlib.Z_SYNC_FLUSH)
|
content += z.flush(zlib.Z_SYNC_FLUSH)
|
||||||
|
|
||||||
@ -68,17 +41,17 @@ 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
|
||||||
|
|
||||||
if "@" in host:
|
if "@" in host:
|
||||||
# split username (and possible password) from the host[:port]
|
# split username (and possible password) from the host[:port]
|
||||||
username, host = host.split("@")
|
username, host = host.rsplit("@", 1)
|
||||||
# Fix #410 bad username error detect
|
# Fix #410 bad username error detect
|
||||||
# username cannot contain an @ sign in this scenario
|
|
||||||
if ":" in username:
|
if ":" in username:
|
||||||
# this will even allow for the username to be empty
|
# this will even allow for the username to be empty
|
||||||
username, password = username.split(":")
|
username, password = username.split(":")
|
||||||
@ -117,7 +90,7 @@ def connect(ssh_cmd, rhostport, python, stderr, options):
|
|||||||
rhost = host
|
rhost = host
|
||||||
|
|
||||||
z = zlib.compressobj(1)
|
z = zlib.compressobj(1)
|
||||||
content = readfile('sshuttle.assembler')
|
content = get_module_source('sshuttle.assembler')
|
||||||
optdata = ''.join("%s=%r\n" % (k, v) for (k, v) in list(options.items()))
|
optdata = ''.join("%s=%r\n" % (k, v) for (k, v) in list(options.items()))
|
||||||
optdata = optdata.encode("UTF8")
|
optdata = optdata.encode("UTF8")
|
||||||
content2 = (empackage(z, 'sshuttle') +
|
content2 = (empackage(z, 'sshuttle') +
|
||||||
@ -145,6 +118,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:
|
||||||
@ -155,12 +132,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()
|
||||||
|
|
||||||
|
@ -10,15 +10,12 @@ from sshuttle.helpers import b, log, debug1, debug2, debug3, Fatal
|
|||||||
MAX_CHANNEL = 65535
|
MAX_CHANNEL = 65535
|
||||||
LATENCY_BUFFER_SIZE = 32768
|
LATENCY_BUFFER_SIZE = 32768
|
||||||
|
|
||||||
# these don't exist in the socket module in python 2.3!
|
|
||||||
SHUT_RD = 0
|
SHUT_RD = 0
|
||||||
SHUT_WR = 1
|
SHUT_WR = 1
|
||||||
SHUT_RDWR = 2
|
SHUT_RDWR = 2
|
||||||
|
|
||||||
|
|
||||||
HDR_LEN = 8
|
HDR_LEN = 8
|
||||||
|
|
||||||
|
|
||||||
CMD_EXIT = 0x4200
|
CMD_EXIT = 0x4200
|
||||||
CMD_PING = 0x4201
|
CMD_PING = 0x4201
|
||||||
CMD_PONG = 0x4202
|
CMD_PONG = 0x4202
|
||||||
|
Reference in New Issue
Block a user