2

I am using sshuttle to route some traffic automatically via an ssh jump server. It works well but in some situations i.e. switching to another Wifi network the connection breaks an i'll have to restart sshuttle manually.

Is it possible to start sshuttle in a way that it restarts automatically whenever a network connection is available again?

We already built a workaround with until which retries in a loop until it connects again, but that feels wrong to me?

1

1 Answer 1

2

Just use systemd for that, first create a systemd service file for sshutle

sudo nano /etc/systemd/system/sshuttle.service

then put this inside ( replace your_username and ssh_jump_server with the address of your ssh jump server and the other by the network you want to route with sshutle )

[Unit]
Description=sshuttle tunnel

[Service]
Restart=always
User=<your_username>
Group=<your_username>
ExecStart=/usr/bin/sshuttle -r <ssh_jump_server> <local_network>

[Install]
WantedBy=multi-user.target

then you can save and reload systemd sudo systemctl daemon-reload then enable our new sshuttle service to start at boot, now the sshutle service is automaticaly restarted when it exit and if the network connection is lost, the sshutle service will automaticaly restart when the connection is working again.

4
  • 1
    Could you explain more about this service? Apr 1, 2023 at 22:09
  • 1
    the sshuttle service will start at boot with sudo systemctl enable sshuttle. The systemd service will automatically restart sshuttle if it exits or if the network connection is lost. Once the connection is restored, the service will restart as well.
    – Saxtheowl
    Apr 2, 2023 at 3:35
  • I don't know why I get error when running this command. Where can I send you my config? Apr 2, 2023 at 7:36
  • this is my question: serverfault.com/questions/1127706/… Apr 2, 2023 at 7:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .