bash cygwin ssh 在退出时给出“被信号 1 杀死”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12639615/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 03:24:52  来源:igfitidea点击:

cygwin ssh gives "Killed by signal 1" on exit

bashsshcygwinsignals

提问by Rop

After using cygwin's ssh to login from windows to linux-hosts, when exiting the remote shell, I always get the annoying msg:

使用cygwin的ssh从windows登录linux-hosts后,退出远程shell时,总是收到烦人的msg:

"Killed by signal 1"

“被信号 1 杀死”

I googled, and realize its harmless, but still annoying... Some suggested you can get rid of the message by using

我用谷歌搜索,并意识到它是无害的,但仍然很烦人......有人建议你可以使用

$ ssh -q ...

$ ssh -q ...

But that has no effect on any of the machines I've tried.

但这对我尝试过的任何机器都没有影响。

Anyone knows a working solution to get rid of this msg?

任何人都知道摆脱这个味精的可行解决方案吗?

采纳答案by Hongbo Liu

Adding following line to your ~/.ssh/configfile can squash that message.

将以下行添加到您的~/.ssh/config文件中可以压缩该消息。

Update: QUIET must be all CAPS & must added for each host in your config.

更新:QUIET 必须全部为大写,并且必须为配置中的每个主机添加。

LogLevel QUIET

Added in first line will squash the message globally. Will only take effect for the specific hosts if it's placed under Host.

添加在第一行将全局压缩消息。如果它被放置在Host.

回答by Irfy

This happens when you proxy your ssh session through another host. Example .ssh/configfile:

当您通过另一台主机代理 ssh 会话时会发生这种情况。示例.ssh/config文件:

# machine with open SSH port
Host proxy
HostName foo.com

# machine accessible only from the above machine
Host target
HostName 192.168.0.12
ProxyCommand ssh proxy nc %h %p

When you exit from an ssh target, the sshin ProxyCommandwill cause the output. If you add the -qthere, it will be suppressed:

当您从 an 退出时ssh targetsshinProxyCommand将导致输出。如果在-q那里添加,它将被抑制:

ProxyCommand ssh -q proxy nc %h %p

You may be surprised that this output has nothing to do with Cygwin -- it happens on Linux as well.

您可能会惊讶于这个输出与 Cygwin 无关——它也发生在 Linux 上。

回答by Irfy

I'm adding a new answer because I have a new solution under different circumstances.

我正在添加一个新答案,因为我在不同情况下有一个新的解决方案。

When using the modern ProxyJumpdirective, there is no place to put the -q, as with ProxyCommand:

使用现代ProxyJump指令时,没有地方放置-q,如ProxyCommand

Host target
  ProxyJump proxy

Instead of switching back to the more manual jump definition with ProxyCommand, the solution with ProxyJumpis to add LogLevel QUIETto a Host proxydefinition:

与使用 切换回更手动的跳转定义不同ProxyCommand,使用 的解决方案ProxyJump是添加LogLevel QUIETHost proxy定义中:

Host target
  ProxyJump proxy
Host proxy
  LogLevel QUIET

which will have the same effect as the -qin ProxyCommand's ssh -q proxy ....

这将对作为同样的效果-qProxyCommandssh -q proxy ...

回答by obor

In a script bash, to get rid of this message, add the following at the top:

在脚本 bash 中,要删除此消息,请在顶部添加以下内容:

exec 2> >(grep -v "Killed by signal 1.")

回答by Jon Nalley

If you enable connection sharing with the ControlMaster directive you can share a single connection when proxying sessions through another host. You can then set the ControlPersist directive to 1 second which will avoid the 'killed by signal 1' error by delaying the termination of the shared connection.

如果使用 ControlMaster 指令启用连接共享,则可以在通过另一台主机代理会话时共享单个连接。然后,您可以将 ControlPersist 指令设置为 1 秒,这将通过延迟共享连接的终止来避免“被信号 1 杀死”错误。

Add the following to your ~/.ssh/config

将以下内容添加到您的 ~/.ssh/config

ControlMaster auto
ControlPersist 1
ControlPath ~/.ssh/.%C

回答by Paul Calabro

Perhaps, you might like PuTTYas an alternative. I don't think it gives that error AND it allows you to do things like save connection info as well as other niceties.

也许,您可能喜欢PuTTY作为替代品。我不认为它会产生该错误,并且它允许您执行诸如保存连接信息以及其他细节之类的操作。

Though I haven't tried it, you might also be able to redirect sterr (which is the stream I believe that message would be sent to) to /dev/null (effectively, the bitbucket or bottomless void where things go to die). You could do possibly do something like:

虽然我还没有尝试过,但您也可以将 sterr(我认为该消息将发送到的流)重定向到 /dev/null(实际上,bitbucket 或无底洞)。你可能会做这样的事情:

ssh user@host 2>/dev/null

ssh 用户@主机 2>/dev/null