So a bit of background, I'm having issues with my port forwarding scripts as they do not actually kill themselves after the time I set.
Here's what I currently have:
Code:
ssh -f -g -L 8080:host:80 user@host sleep 3600
I've been testing out the command timeout:
Code:
timeout 10 ssh -f -g -L 8080:host1:80 user@host1
but when I try to run the command I get the following:
Code:
Cannot fork into background without a command to execute.
I've also been looking into creating a config file just for these types of commands, but I don't see any values I can set to always kill the tunnel (TCPKeepAlive, ServerAliveInterval, are all based on data transfer)
Basically my main question is why am I unable execute the timeout command when I force it to the background?
A few other questions:
1) can you think of a way to get the connection to kill itself after an hour no matter what?
2) What data is being transferred when you're connected to a host but not running any commands (basically why is ServerAliveInterval not terminating if I ssh and do nothing)?