Background SSHPublished on 24 Mar 2004
SSH usually operates in the foreground where it provides an interactive login or displays the output of a remote command (see remote commands). Although using the forwarding services (see port forwarding and agent forwarding) requires successful authentication, it does not have to result in a shell.
Therefore, SSH may be pushed into the background with the
-f parameter just before the command is executed:
ssh -f HOST COMMAND
The only requirement is using a remote command (see remote commands). This is especially useful if running a remote X client for which the SSH tunnel will remain active until the command terminates.
There is also a way of restricting such a forwarding to an interval of time:
ssh -f HOST sleep N
Independent of the actual usage, the instance of SSH will terminate after
Most of the time you will probably want a forwarding to be available for an unlimited amount of time:
ssh -fN HOST
-N parameter prevents the execution of a remote command.)