How do I kill a backgrounded/detached ssh session?

前端 未结 11 1219
刺人心
刺人心 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条回答
  •  有刺的猬
    2020-12-01 00:22

    well i dont want to add an & at the end of the commands as the connection will die if the console wintow is closed ... so i ended up with an ps-grep-awk-sed-combo

    ssh -f -N -L localhost:12345:otherHost:12345   otherUser@otherHost
    echo `ps aux | grep -F 'ssh -f -N -L localhost' | grep -v -F 'grep' | awk '{ print $2 }'` > /tmp/synergyPIDs/ssh
    synergyc localhost
    echo `ps aux | grep -F 'synergyc localhost' | grep -v -F 'grep' | awk '{ print $2 }'` > /tmp/synergyPIDs/synergy
    

    (you could integrate grep into awk, but im too lazy now)

提交回复
热议问题