How do I kill a backgrounded/detached ssh session?

前端 未结 11 1253
刺人心
刺人心 2020-12-01 00:02

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         


        
11条回答
  •  Happy的楠姐
    2020-12-01 00:41

    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"
    

提交回复
热议问题