How do I kill a backgrounded/detached ssh session?

前端 未结 11 1254
刺人心
刺人心 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:22

    You can drop the -f, which makes it run it in background, then run it with eval and force it to the background yourself.

    You can then grab the pid. Make sure to put the & within the eval statement.

    eval "ssh -N -L localhost:12345:otherHost:12345 otherUser@OtherHost & " 
    tunnelpid=$!
    

提交回复
热议问题