Score:2

How to restart sshuttle automatically

sa flag

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?

Mj Ebrahimzadeh avatar
br flag
Did you find any solution?
Score:2
by flag

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.

Mj Ebrahimzadeh avatar
br flag
Could you explain more about this service?
Saxtheowl avatar
by flag
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.
Mj Ebrahimzadeh avatar
br flag
I don't know why I get error when running this command. Where can I send you my config?
Mj Ebrahimzadeh avatar
br flag
this is my question: https://serverfault.com/questions/1127706/sshuttle-automate-service-runs-with-error
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.