I am using the program synergy together with an ssh tunnel
It works, i just have to open an console an type these two commands:
ssh -f -N -L localhos
You can use lsof to show the pid of the process listening to port 12345 on localhost:
lsof -t -i @localhost:12345 -sTCP:listen
Examples:
PID=$(lsof -t -i @localhost:12345 -sTCP:listen) lsof -t -i @localhost:12345 -sTCP:listen >/dev/null && echo "Port in use"