Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forwarding SIGTERM over ssh

Tags:

ssh

signals

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?

like image 579
guettli Avatar asked Jan 22 '18 09:01

guettli


People also ask

How do I enable X11 forwarding over SSH?

Enabling X11 Forwarding in your SSH Client To be certain it is enabled, you may use ssh -X. PuTTY: Prior to connection, in your connection's options, under "Tunnels", check "Enable X11 forwarding", and save your connection. MobaXterm: X11 is automatically enabled.

Can Sigterm be ignored?

The SIGTERM signal is a generic signal used to cause program termination. Unlike SIGKILL , this signal can be blocked, handled, and ignored.


1 Answers

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 .

like image 187
Sahil Aggarwal Avatar answered Oct 12 '22 10:10

Sahil Aggarwal