My final goal is to use both ssh -f and sshpass together, although it is quite not works. ssh -f tries to fork from the ssh process and also sets stdin to read from /dev/null - what makes things difficult because sshpass gathers the ssh command, executes it and passes the password to it as input (stdin). I don't want to use & because basically it's not an elegant way to solve it. Also, sshpass does not support this incident.
Example for command:
sshpass -p pass1234 ssh -L 1234:127.0.0.1:5678 -N -f root@1.2.3.4
If you either remove the '-f' flag or remove the 'sshpass' command you'll see it works great.
Does anyone have an idea how to solve this incident? Thanks.