I’ve built a Fabric fabfile with a simple task to give me a remote interactive shell:
def shell():
open_shell()
I do this instead of a raw ssh to save typing: the fabfile already has key paths, host name, etc for each remote config.
Invoking
fab shell
works, but if I ever hit CTRL+C in the shell, it kills the whole connection.
Is it possible to make CTRL+C go to the remote interactive shell instead?
The only one of the ssh libraries I’ve seen for python that uses the signal passing mechanism described by the ssh rfc is the one from chilkatsoft.
From RFC 4254:
You could modify fabric to use that instead of the ‘ssh’ library, and then add a signal handler to fabric to catch the SIGINT and call SendReqSignal() to send it along to the remote process.
or you could probably just wrap fabric with stty invocations to change the INTR character to something else, and then change it back afterwards.