Remote interactive shell with Fabric killed by CTRL-C

I created a Fab Fab fabfile with a simple task to give me a remote interactive shell:

def shell(): open_shell() 

I am doing this instead of raw ssh to save input: fabfile already has key paths, hostname, etc. for each remote configuration.

Call

 fab shell 

works, but if I ever hit CTRL + C in a shell, it killed the whole connection.

Is it possible to do CTRL + C instead of a remote interactive shell?

+4
source share
1 answer

The only ssh library I've seen for python that uses the signal transfer mechanism described by ssh rfc is the only one from chilkatsoft. From RFC 4254:

 6.9. Signals A signal can be delivered to the remote process/service using the following message. Some systems may not implement signals, in which case they SHOULD ignore this message. byte SSH_MSG_CHANNEL_REQUEST uint32 recipient channel string "signal" boolean FALSE string signal name (without the "SIG" prefix) 'signal name' values will be encoded as discussed in the passage describing SSH_MSG_CHANNEL_REQUEST messages using "exit-signal" in this section. 

You can change the structure to use this instead of the 'ssh' library, and then add a signal handler to the fabric to catch SIGINT and call SendReqSignal () to send it to the remote process.

or you could just wrap the fabric with strict calls to change the INTR character to something else, and then change it again.

 #!/bin/sh stty intr ^U <whatever to invoke fabric> stty intr ^C 
+2
source

Source: https://habr.com/ru/post/1400790/


All Articles