Temporary solution: For now I am using a systemd service to handle this, using invoke to respond to the password.

I am having trouble executing the following command over SSH:

ssh -t user@host "sshuttle -D --dns -r user@host:port -x 0/0"

working (no daemon):

ssh -user1@host1 ssh user2@host2 'sudo sshuttle --dns -r user3@host3:port -x 0/0'

Doesn't work (with daemon and sleep):

ssh -user1@host1 ssh user2@host2 'sudo sshuttle -D --dns -r user3@host3:port -x 0/0 && curl ifconfig.co && sleep 3'

I have determined that the issue is entirely due to the -D (daemon) argument.

  • This code works when run locally (on the remote server)
  • The issue is not due to superuser privileges.
  • I have tried many combinations (including manually invoking bash -c and bash -s.)
  • I have deployed a bash script remotely and have executed the script over SSH to start the tunnel.
  • I have tried dropping the -D arg and using nohup and & (together and separately).
  • I have modified "/etc/systemd/logind.conf" to "KillUserProcesses=no"

All attempts result in the successful return/exit codes, yet, no tunnel is initiated. If I drop the daemon arg it works fine, but I need it alive in the background.

Any ideas on how I can execute the sshuttle daemonized over SSH?

1 Answer 1


Have you tried running ssh with the -t flag? It might be that sshuttle requires a tty in order to run. the -t flag forces a psuedo-terminal on the connection.

If that doesn't work, another option may be to try running the process in a screen. eg:

ssh user1@host  'screen -dmS myscreen mycommand.sh'  

This gives the process a place to write it's output. Since you have a lot of metacharacters in your sshuttle command, you may need to place those in a startup script somewhere on the remote system (such as mycommand.sh) or try to figure out how best to escape the characters (such as && and @) to get it all to run in one line.

  • Hi, thank you for replying. I have used -t and -tt, yes. I have created a systemd startup script and even a python script to autorespond to the password. The tunnel wont initialize although there's no error warning.
    – Evan
    Commented Nov 13, 2019 at 2:35
  • I will look into screen ad update/award you if it works out.
    – Evan
    Commented Nov 13, 2019 at 2:40

You must log in to answer this question.

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