How do I kill a backgrounded/detached ssh session?

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

    Quick summary: Will not work.

    My first idea is that you need to start the processes in the background to get their PIDs with $!.

    A pattern like

    some_program &
    some_pid=$!
    wait $some_pid
    

    might do what you need... except that then ssh won't be in the foreground to ask for passphrases any more.

    Well then, you might need something different after all. ssh -f probably spawns a new process your shell can never know from invoking it anyway. Ideally, ssh itself would offer a way to write its PID into some file.

提交回复
热议问题