I would like to use ssh with port forwarding by default. So I added the following ssh command to a script (with made-up server names):
ssh -f -N user@server -L 8080:server:8080
server is a remote server. Everything works except that if the script is run a second time, ssh complains that
bind [127.0.0.1]:8080: Address already in use
Is there a way to tell
ssh to test and do the port-forwarding only when the port/address is available?