SSHUTTLE(1)
π sshuttle(1) β the ssh-powered VPN that's giving main character energy β¨
π NAME π
sshuttle β sshuttle documentation
Okay bestie, that's the official name line. The vibes? Immaculate.
πΈ SYNOPSIS πΈ
Here's the one-line summoning ritual:
sshuttle [options] -r [username@]sshserver[:port] <subnets ...>
π¦ DESCRIPTION π¦
Okay so sshuttle allows you to create a VPN connection from your machine to any remote server that you can connect to via ssh, as long as that server has a sufficiently new Python installation. Yes, that's the whole magic trick.
To work, you must have root access on the local machine, but you can have a normal account on the server. Lowkey the best deal.
It's valid to run sshuttle more than once simultaneously on a single client machine, connecting to a different server every time, so you can be on more than one VPN at once. Multi-VPN main character behavior, honestly.
If run on a router, sshuttle can forward traffic for your entire subnet to the VPN. Router era activated.
π OPTIONS π
Okay, now the part you actually came for: every flag, every placeholder, every default. No skipping, no cap. β¨
<subnets>β A list of subnets to route over the VPN, in the forma.b.c.d[/width][port[-port]]. Valid examples are1.2.3.4(a single IP address) and1.2.3.4/32(equivalent to1.2.3.4),1.2.3.0/24(a 24-bit subnet, ie. with a255.255.255.0netmask). Specify subnets0/0to match all IPv4 addresses and::/0to match all IPv6 addresses. Any of the previous examples are also valid if you append a port or a port range, so1.2.3.4:8000will only tunnel traffic that has as the destination port8000of1.2.3.4and1.2.3.0/24:8000-9000will tunnel traffic going to any port between8000and9000(inclusive) for all IPs in the1.2.3.0/24subnet. A hostname can be provided instead of an IP address. If the hostname resolves to multiple IPs, all of the IPs are included. If a width is provided with a hostname, the width is applied to all of the hostname's IPs (if they are all either IPv4 or IPv6). Widths cannot be supplied to hostnames that resolve to both IPv4 and IPv6. Valid examples areexample.com,example.com:8000,example.com/24,example.com/24:8000andexample.com:8000-9000. That's the whole subnet vibe check.--method <auto|nat|nft|tproxy|pf|ipfw>β Which firewall method shouldsshuttleuse? Forauto,sshuttleattempts to guess the appropriate method depending on what it can find inPATH. The default value isauto. Auto is the default bestie, it's got you.-l <[ip:]port>, --listen=<[ip:]port>β Use this ip address and port number as the transparent proxy port. By defaultsshuttlefinds an available port automatically and listens on IP127.0.0.1(localhost), so you don't need to override it, and connections are only proxied from the local machine, not from outside machines. If you want to accept connections from other machines on your network (ie. to runsshuttleon a router) try enabling IP Forwarding in your kernel, then using--listen 0.0.0.0:0. You can use any name resolving to an IP address of the machine runningsshuttle, e.g.--listen localhost.
For the nft, tproxy and pf methods this can be an IPv6 address. Use this option with comma separated values if required, to provide both IPv4 and IPv6 addresses, e.g. --listen 127.0.0.1:0,[::1]:0. IPv6 girlies, this one's for you.
-H,--auto-hostsβ Scan for remote hostnames and update the local/etc/hostsfile with matching entries for as long as the VPN is open. This is nicer than changing your system's DNS (/etc/resolv.conf) settings, for several reasons. First, hostnames are added without domain names attached, so you can sshthatserverwithout worrying if your local domain matches the remote one. Second, if you sshuttle into more than one VPN at a time, it's impossible to use more than one DNS server at once anyway, butsshuttlecorrectly merges/etc/hostsentries between all running copies. Third, if you're only routing a few subnets over the VPN, you probably would prefer to keep using your local DNS server for everything else.
sshuttle tries to store a cache of the hostnames in ~/.sshuttle.hosts on the remote host. Similarly, it tries to read the file when you later reconnect to the host with --auto-hosts enabled to quickly populate the host list. When troubleshooting this feature, try removing this file on the remote host when sshuttle is not running. Cache era, but make it cute.
-N,--auto-netsβ In addition to the subnets provided on the command line, ask the server which subnets it thinks we should route, and route those automatically. The suggestions are taken automatically from the server's routing table.
Heads up: This feature does not detect IPv6 routes. Specify IPv6 subnets manually. For example, specify the ::/0 subnet on the command line to route all IPv6 traffic. Manual IPv6 bestie, don't forget.
--dnsβ Capture local DNS requests and forward to the remote DNS server. All queries to any of the local system's DNS servers (/etc/resolv.confand, if it exists,/run/systemd/resolve/resolv.conf) will be intercepted and resolved on the remote side of the tunnel instead, there using the DNS specified via the--to-nsoption, if specified. Only plain DNS traffic sent to these servers on port53are captured. DNS said "not today, local resolver."--ns-hosts=<server1[,server2[,server3[...]]]>β Capture local DNS requests to the specified server(s) and forward to the remote DNS server. Contrary to the--dnsoption, this flag allows to specify the DNS server(s) the queries to which to intercept, instead of intercepting all DNS traffic on the local machine. This can be useful when only certain DNS requests should be resolved on the remote side of the tunnel, e.g. in combination withdnsmasq. Selective DNS interception? Obsessed.--to-ns=<server>β The DNS to forward requests to when remote DNS resolution is enabled. If not given,sshuttlewill simply resolve using the system configured resolver on the remote side (via/etc/resolv.confon the remote side). Remote resolver doing its thing.--pythonβ Specify the name/path of the remote python interpreter. The default is to usepython3(orpython, ifpython3fails) in the remote system'sPATH. Python bestie, obviously.-r <[username@]sshserver[:port]>, --remote=<[username@]sshserver[:port]>β The remote hostname and optional username and ssh port number to use for connecting to the remote server. For example,example.com,<testuser@example.com>,<testuser@example.com>:2222, orexample.com:2244. This hostname is passed to ssh, so it will recognize any aliases and settings you may have configured in~/.ssh/config. ssh config girlies rise up.-x <subnet>, --exclude=<subnet>β Explicitly exclude this subnet from forwarding. The format of this option is the same as the<subnets>option. To exclude more than one subnet, specify the-xoption more than once. You can say something like0/0 -x 1.2.3.0/24to forward everything except the local subnet over the VPN, for example. Not that one, bestie.-X <file>, --exclude-from=<file>β Exclude the subnets specified in a file, one subnet per line. Useful when you have lots of subnets to exclude. List girlies, this is your moment.-v,--verboseβ Print more information about the session. This option can be used more than once for increased verbosity. By default,sshuttleprints only error messages. Turn the yapping up, bestie.-e,--ssh-cmdβ The command to use to connect to the remote server. The default is justssh. Use this if your ssh client is in a non-standard location or you want to provide extra options to the ssh command, for example,-e 'ssh -v'. Custom ssh command? Say less.--remote-shellβ For Windows targets, specify configured remote shell program alternative to defacto posix shell. It would be eithercmdorpowershellunless something likegit-bashis in use. Windows besties have options.--no-cmd-delimiterβ Do not add a double dash (--) delimiter before invoking Python on the remote host. This option is useful when the ssh command used to connect is a custom command that does not interpret this delimiter correctly. No--? No problem.--seed-hostsβ A comma-separated list of hostnames to use to initialize the--auto-hostsscan algorithm.--auto-hostsdoes things like pollnetstatoutput for lists of local hostnames, but can speed things up if you use this option to give it a few names to start from.
If this option is used without --auto-hosts, then the listed hostnames will be scanned and added, but no further hostnames will be added. Seed the host list, queen.
--no-latency-controlβ Sacrifice latency to improve bandwidth benchmarks. ssh uses really big socket buffers, which can overload the connection if you start doing large file transfers, thus making all your other sessions inside the same tunnel go slowly. Normally,sshuttletries to avoid this problem using a "fullness check" that allows only a certain amount of outstanding data to be buffered at a time. But on high-bandwidth links, this can leave a lot of your bandwidth underutilized. It also makessshuttleseem slow in bandwidth benchmarks (benchmarks rarely test ping latency, which is whatsshuttleis trying to control). This option disables the latency control feature, maximizing bandwidth usage. Use at your own risk. No cap, it's giving chaos.--latency-buffer-sizeβ Set the size of the buffer used in latency control. The default is32768. Changing this option allows a compromise to be made between latency and bandwidth without completely disabling latency control (with--no-latency-control). Buffer tuning, but make it balanced.-D,--daemonβ Automatically fork into the background after connecting to the remote server. Implies--syslog. Background mode: activated.-s <file>, --subnets=<file>β Include the subnets specified in a file instead of on the command line. One subnet per line. File girlies stay winning.--syslogβ after connecting, send all log messages to thesyslog(3)service instead ofstderr. This is implicit if you use--daemon. Logs? To syslog? It's giving organized.--pidfile=<pidfilename>β when using--daemon, savesshuttle's pid topidfilename. The default issshuttle.pidin the current directory. PID file, cute.--disable-ipv6β Disable IPv6 support for methods that support it (nat,nft,tproxy, andpf). IPv6? Not for this method, bestie.--firewallβ (internal use only) run the firewall manager. This is the only part ofsshuttlethat must run as root. If you startsshuttleas a non-root user, it will automatically runsudoorsuto start the firewall manager, but the core ofsshuttlestill runs as a normal user. Internal use only β don't touch unless you know the lore.--hostwatchβ (internal use only) runs thehostwatchdaemon β¨ this lil process lives on the server side and scoops up hostnames for the--auto-hostsoption. Using it on its own makes debugging and testing--auto-hostsso much easier, ngl π«Ά--sudoers-no-modifyβ sshuttle prints a config to stdout that lets a user run sshuttle without a password. Bestie, listen: this option is INSECURE π because with some cleverness it also lets the user run any command as root without a password. The output also includes a suggested method for you to install the configuration. Use--sudoers-userto modify the user that it applies to.--sudoers-userβ sets the user name, or group with%group_name, for passwordless operation. Default is the current user. Set it toALLfor all users (NOT RECOMMENDED: See note about security in--sudoers-no-modifydocumentation above). Only works with the--sudoers-no-modifyoption π-t <mark>,--tmark=<mark>β an option used by thetproxymethod: use the specified traffic mark. The mark must be a hexadecimal value. Defaults to0x01β--versionβ prints program version π
π¦ CONFIGURATION FILE π¦
All the options described above can optionally be specified in a configuration file. Yes, all of them π
To run sshuttle with options defined in, e.g., /etc/sshuttle.conf just pass the path to the file preceded by the @ character, e.g. @/etc/sshuttle.conf.
When running sshuttle with options defined in a configuration file, options can still be passed via the command line in addition to what's defined in the file. And if a given option shows up both in the file and on the command line, the value in the command line takes precedence π
Arguments read from a file must be one per line, as shown below:
value
--option1
value1
--option2
value2
The configuration file supports comments for human-readable annotations π§ For example:
# company-internal API
8.8.8.8/32
# home IoT
192.168.63.0/24
π ENVIRONMENT VARIABLE π
You can specify command line options with the SSHUTTLE_ARGS environment variable β¨ If a given option is defined in both the environment variable and command line, the value on the command line will take precedence.
For example:
SSHUTTLE_ARGS="-e 'ssh -v' --dns" sshuttle -r example.com 0/0
π EXAMPLES π
Use the following command to route all IPv4 TCP traffic through the remote (-r) host example.com (and possibly other traffic too, depending on the selected --method). The 0/0 subnet, short for 0.0.0.0/0, matches all IPv4 addresses. The ::/0 subnet, matching all IPv6 addresses, could be added to the example. The SSH connection endpoint is automatically excluded from forwarding. When ProxyCommand is configured, automatic exclusion is skipped; use -x to exclude the required address manually. Press Ctrl+C to exit π To also route DNS queries through sshuttle, try adding --dns. Add or remove -v options to see more or less information:
$ sshuttle -r example.com 0/0
Starting sshuttle proxy (version ...).
[local sudo] Password:
fw: Starting firewall with Python version 3.9.5
fw: ready method name nat.
c : IPv6 disabled since it isn't supported by method nat.
c : Method: nat
c : IPv4: on
c : IPv6: off (not available with nat method)
c : UDP : off (not available with nat method)
c : DNS : off (available)
c : User: off (available)
c : Subnets to forward through remote host (type, IP, cidr mask width, startPort, endPort):
c : (<AddressFamily.AF_INET: 2>, '0.0.0.0', 0, 0, 0)
c : Subnets to exclude from forwarding:
c : (<AddressFamily.AF_INET: 2>, '127.0.0.1', 32, 0, 0)
c : (<AddressFamily.AF_INET: 2>, '...', 32, 0, 0)
c : TCP redirector listening on ('127.0.0.1', 12299).
c : Starting client with Python version 3.9.5
c : Connecting to server...
user@example.com's password:
s: Starting server with Python version 3.6.8
s: latency control setting = True
s: auto-nets:False
c : Connected to server.
fw: setting up.
fw: iptables -w -t nat -N sshuttle-12299
fw: iptables -w -t nat -F sshuttle-12299
...
Accept: 192.168.42.121:60554 -> 77.141.99.22:22.
^C
c : Keyboard interrupt: exiting.
c : SW'unknown':Mux#1: deleting (1 remain)
c : SW#7:192.168.42.121:60554: deleting (0 remain)
Connect to a remote server, with automatic hostname and subnet guessing π:
$ sshuttle -vNHr example.com
Starting sshuttle proxy (version ...).
[local sudo] Password:
fw: Starting firewall with Python version 3.9.5
fw: ready method name nat.
c : IPv6 disabled since it isn't supported by method nat.
c : Method: nat
c : IPv4: on
c : IPv6: off (not available with nat method)
c : UDP : off (not available with nat method)
c : DNS : off (available)
c : User: off (available)
c : Subnets to forward through remote host (type, IP, cidr mask width, startPort, endPort):
c : NOTE: Additional subnets to forward may be added below by --auto-nets.
c : Subnets to exclude from forwarding:
c : (<AddressFamily.AF_INET: 2>, '127.0.0.1', 32, 0, 0)
c : (<AddressFamily.AF_INET: 2>, '...', 32, 0, 0)
c : TCP redirector listening on ('127.0.0.1', 12300).
c : Starting client with Python version 3.9.5
c : Connecting to server...
user@example.com's password:
s: Starting server with Python version 3.6.8
s: latency control setting = True
s: auto-nets:True
c : Connected to server.
c : seed_hosts: []
s: available routes:
s: 77.141.99.0/24
fw: setting up.
fw: iptables -w -t nat -N sshuttle-12300
fw: iptables -w -t nat -F sshuttle-12300
...
c : Accept: 192.168.42.121:60554 -> 77.141.99.22:22.
^C
c : Keyboard interrupt: exiting.
c : SW'unknown':Mux#1: deleting (1 remain)
c : SW#7:192.168.42.121:60554: deleting (0 remain)
Run sshuttle with a /etc/sshuttle.conf configuration file π¦:
$ sshuttle @/etc/sshuttle.conf
Use the options defined in /etc/sshuttle.conf but be more verbose:
$ sshuttle @/etc/sshuttle.conf -vvv
Override the remote server defined in /etc/sshuttle.conf:
$ sshuttle @/etc/sshuttle.conf -r otheruser@test.example.com
Example configuration file πΈ:
192.168.0.0/16
--remote
user@example.com
π₯ DISCUSSION π₯
When it starts, sshuttle creates an ssh session to the server specified by the -r option β¨
After connecting to the remote server, sshuttle uploads its (python) source code to the remote end and executes it there. So you don't need to install sshuttle on the remote server, and there are never sshuttle version conflicts between client and server π iconic behavior honestly.
Unlike most VPNs, sshuttle forwards sessions, not packets. That is, it uses kernel transparent proxying (iptables REDIRECT rules on Linux) to capture outgoing TCP sessions, then creates entirely separate TCP sessions out to the original destination at the other end of the tunnel π«Ά
Packet-level forwarding (eg. using the tun/tap devices on Linux) seems elegant at first, but it results in several problems, notably the 'tcp over tcp' problem π The tcp protocol depends fundamentally on packets being dropped in order to implement its congestion control algorithm; if you pass tcp packets through a tcp-based tunnel (such as ssh), the inner tcp packets will never be dropped, and so the inner tcp stream's congestion control will be completely broken, and performance will be terrible. Thus, packet-based VPNs (such as IPsec and openvpn) cannot use tcp-based encrypted streams like ssh or ssl, and have to implement their own encryption from scratch, which is very complex and error prone π
sshuttle's simplicity comes from the fact that it can safely use the existing ssh encrypted tunnel without incurring a performance penalty. It does this by letting the client-side kernel manage the incoming tcp stream, and the server-side kernel manage the outgoing tcp stream; there is no need for congestion control to be shared between the two separate streams, so a tcp-based tunnel is fine β
π Author π
Brian May
π Copyright π
2016, Brian May
and that's the whole page bestie, you ate that π β¨ This gorgeous lil manual is from sshuttle 2.0, dated Sep 30, 2026 β go forth and tunnel responsibly π¦π
π¦ where this page comes from
- arch rolling: sshuttle 2.0.0-1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms