Skip to content

send signals to process in through channel #221

@jimy-byerley

Description

@jimy-byerley

Hello an thanks for that library
Is it possible in ssh2-python to the current process running in a channel, like it is in the ssh specs ?

for instance on paramiko you basically can't but you can always hack it with the private API:

from paramiko import Message
from paramiko.common import cMSG_CHANNEL_REQUEST
from signal import Signals

# trigger termination with a standard openssh packet (since v7.6) but using the private API of paramiko because it doesn't natively implements it
# spec: https://www.ietf.org/rfc/rfc4254.txt
message = Message()
message.add_byte(cMSG_CHANNEL_REQUEST)
message.add_int(channel.remote_chanid)
message.add_string("signal")
message.add_boolean(False)
message.add_string(Signals.SIGTERM.name[3:])
client.get_transport()._send_user_message(message)

It would greatly help me since i'm using SIGTERM and SIGINT signals to stop the continuously running processes i'm starting over ssh

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions