cygwin ssh gives “Killed by signal 1” on exit

◇◆丶佛笑我妖孽 提交于 2019-12-03 22:32:01
Hongbo Liu

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

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

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.

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

# 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 ssh in ProxyCommand will cause the output. If you add the -q there, it will be suppressed:

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.

Perhaps, you might like PuTTY as 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.

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:

ssh user@host 2>/dev/null

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.

Add the following to your ~/.ssh/config

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

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

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

Host target
  ProxyJump proxy

Instead of switching back to the more manual jump definition with ProxyCommand, the solution with ProxyJump is to add LogLevel QUIET to a Host proxy definition:

Host target
  ProxyJump proxy
Host proxy
  LogLevel QUIET

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!