繁体   English   中英

带Fabric的远程交互式Shell被CTRL-C杀死

[英]Remote interactive shell with Fabric is killed by CTRL-C

我用一个简单的任务构建了一个fabric fabfile,为我提供了一个远程交互式shell:

def shell():
  open_shell()

我这样做是为了代替原始ssh来保存输入内容:fabfile已经具有每个远程配置的键路径,主机名等。

调用中

fab shell

可以,但是如果我在外壳中按CTRL + C ,它将终止整个连接。

是否可以使CTRL + C转到远程交互式外壳?

我见过的python唯一使用ssh rfc描述的信号传递机制的ssh库是chilkatsoft的库。 从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.

您可以修改结构以使用该结构而不是'ssh'库,然后向该结构添加一个信号处理程序以捕获SIGINT并调用SendReqSignal()将其发送到远程进程。

或者您可能只是用stty调用包装结构,以将INTR字符更改为其他字符,然后再将其更改回。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM