Using Sshuttle as a service

1 — Service Account

groupadd sshuttle
useradd -d /home/sshuttle -g sshuttle sshuttle
mkdir /home/sshuttle/.ssh
chown -R sshuttle:sshuttle /home/sshuttle
chmod 700 /home/sshuttle/.ssh
ssh-keygen -o -a 100 -t ed25519 -N "" -C "sshuttle_key" -f /home/sshuttle/.ssh/id_ed25519
root@client> su sshuttle
sshuttle@client> ssh targetServer

2 — Sudo access

sshuttle ALL=(root) NOPASSWD: /usr/bin/python /usr/share/sshuttle/ /usr/bin/python --firewall 12*** 0

3 — Install package

root@client> yum install sshuttle

4 — Service scripts

root@client> vi /etc/systemd/system/sshuttle.service[Unit]
Description=sshuttle service
ExecStart=/etc/sshuttle/ start
ExecStop=/etc/sshuttle/ stop
systemctl daemon-reload
mkdir /etc/sshuttle
chown sshuttle:sshuttle /etc/sshuttle
sshuttle@client>  vi /etc/sshuttle/
# make script executable
chmod +x /etc/sshuttle/
systemctl status sshuttle
systemctl start sshutle
systemctl stop sshuttle

5 — Config File

sshuttle@client> vi /etc/sshuttle/config.json{
"HopServerA": [
"HopServerB": [
systemctl restart sshuttle
cat /srv/salt/pillar/servers/nycweb01.slssshuttle:
- # customer A
- # customer B
- # customer C
- # ftp customer D
- # customer F

Update #1 — Keep Alive

rpath = "-r {0}@{1} {2} -l listen '' --ssh-cmd 'ssh -o ServerAliveInterval=60' --no-latency-control".format(ssh_user, rhost, netrange)
--ssh-cmd 'ssh -o ServerAliveInterval=60' --no-latency-control'

Update #2 — Proxying via 2 or more hops

A needs to get to D, via B and C
# config.json on server A{
"0:serverB": [
"serverC hostname or IP",
"1:serverC": [
"serverD hostname or IP"
# config.json on server B
"serverC": [
"serverD hostname or IP"
sleep 3 to establish an SSH handshake
rpath = "-r {0}@{1} {2} -l {{ salt['pillar.get']('sshuttle:listen', '') }} --ssh-cmd 'ssh -o ServerAliveInterval=60' --no-latency-control".format(ssh_user, rhost, netrange)
## Server B pillar
- serverD ip or hostname
rpath = "-r {0}@{1} {2} -l --no-latency-control".format(ssh_user, rhost, netrange)
#3 connection will only start after #1 is established




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Customers will not come just because you build it

Spark Interview Guide : Part 3 : Spark SQL & Dataframe

A ‘real-world’ framework for backtesting Uniswap V3 strategies

CS371p Spring 2021: Joshua Brown

Neo-vim vs Vim

NeuML — 2021 Year in Review

How to create timed effects for enhanced user interaction (Part 1)

Why learn python?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mike R

Mike R

More from Medium

Auto enable tap-to-click on Surface Pro 4 after suspend with libinput

re-enable from mouse setting menu

How to Install jq(JSON processor) on RHEL/CentOS

Little Little Troubleshooting for Various Things

How to check the version before installing a package using apt-get?