Forwarding SIGTERM over ssh

2019-04-20 23:02发布

问题:

I want ssh to forward the SIGTERM signal to the remote command.

ssh root@localhost /root/print-signal.py

Get PID of ssh:

ps aux| grep print-signal

Kill the matching ssh process:

kill pid-of-ssh

Unfortunately only the ssh process itself gets the signal, not the remote command (print-signal.py). The remote command does not terminate :-(

How can I make ssh "forward" the SIGTERM signal to the remote command?

回答1:

I think you can do the following :

ssh root@localhost /root/print-signal.py

**Get PID of python file running **

ps aux| grep print-signal

Kill the matching ssh process:

ssh root@localhost "kill <pid>"

Here you are sending command to remote host .

Hope this solves your problem .



回答2:

Send via SSH this (tested on sleep process):

$(proc=$(pidof sleep) && kill $proc)


标签: ssh signals