I'm trying to open a tunnel on a remote server from local machine by executing a command remotely via ssh. I'm using sshpass too.
sshpass -fpw_file.txt ssh email@example.com 'bash /home/username/do_stuff.sh &'
This do_stuff.sh contains just one line:
ssh -f -N -L 8888:hostname:9999 user@host &
But the call (first command) is not returning. If I put & outside the single quotes, it spawns a process which is not getting killed. Although it is a very small memory leak, it would be good to know if there is a way to do this cleanly.