Skip to content

send signals to process in through channel #221

Closed

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

Activity

  1. pkittenis commented on Aug 25, 2025

    @pkittenis
    Member

    Thanks for the interest.

    The function libssh2 uses for passing ad-hoc signals is not implemented yet - would be ssh2.Channel.signal.

  2. added a commit that references this issue on Oct 4, 2025
    ed92d02
  3. added a commit that references this issue on Nov 17, 2025
    b4413bf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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