简体   繁体   English

在 Windows 上使用 Cygwin 的 SSH ControlMaster 实际上可能吗?

[英]Is SSH ControlMaster with Cygwin on Windows actually possible?

Has anyone been able to use control master with cygwin on Windows to create multiple sessions without having to log on repeatedly?有没有人能够在 Windows 上使用带有 cygwin 的 control master 来创建多个会话而无需重复登录? I need to automate a succession of SSH steps but cannot ask the user to enter the required tokenized password eachtime.我需要自动执行一系列 SSH 步骤,但不能要求用户每次都输入所需的令牌化密码。

I have configured my cygwin ssh_config with following:我已经使用以下配置了我的 cygwin ssh_config:

Host *
    ControlMaster auto
    ControlPath /tmp/%r@%h:%p

And I get the following error message on the master when I start a second connection which prompts for the password again:当我启动第二个连接时,我在主服务器上收到以下错误消息,再次提示输入密码:

mm_receive_fd: no message header
process_mux_new_session: failed to receive fd 0 from slave

I've seen others with this problem but I can't seem to find any solution for this.我见过其他人有这个问题,但我似乎找不到任何解决方案。

Has anyone made this work?有没有人做过这个工作?

Apparently the conclusion after much searching is that currently it is NOT possible.显然,经过多次搜索后的结论是,目前这是不可能的。 These were the only links I found that dealt with this:这些是我发现的唯一处理此问题的链接:

https://stackoverflow.com/questions/17140457/imitating-a-shared-ssh-session-for-scripts-on-windows "...but there is no implementation of OpenSSH for Windows which does this (file descriptors over unix sockets do not work in Cygwin)." https://stackoverflow.com/questions/17140457/imitating-a-shared-ssh-session-for-scripts-on-windows “...但是没有实现 Windows 的 OpenSSH 执行此操作(Unix 上的文件描述符)套接字在 Cygwin 中不起作用)。” and

http://gcc.gnu.org/wiki/SSH_connection_caching "Unfortunately if you are using OpenSSH on Cygwin you will not be able to take advantage of connection caching because Cygwin does not currently support file descriptor passing via unix-domain sockets." http://gcc.gnu.org/wiki/SSH_connection_caching “不幸的是,如果您在 Cygwin 上使用 OpenSSH,您将无法利用连接缓存,因为 Cygwin 当前不支持通过 unix 域套接字传递文件描述符。”

For Cygwin it still seems not possible, but in Windows, it is possible.对于 Cygwin 似乎仍然不可能,但在 Windows 中,它是可能的。 I have this working in windows using wsl-ssh-pageant and the Windows Ubuntu Bash/WSL).我使用 wsl-ssh-pageant 和 Windows Ubuntu Bash/WSL 在 Windows 中进行了这项工作)。

Under bash install socat.在 bash 下安装 socat。 Then run wsl-ssh-pageant as it says, then with the while loop and export.然后按照说明运行 wsl-ssh-pageant,然后使用 while 循环并导出。 If you have your controlmaster under .ssh setup correctly and the directory for ControlPath is created, is should work.如果您在 .ssh 下正确设置了 controlmaster 并且创建了 ControlPath 目录,则应该可以使用。

Bug 1278 - CYGWIN controlMaster connections don't work.错误 1278 - CYGWIN controlMaster 连接不起作用。 describes use of ControlMaster/ControlPersist as partially implemented under Cygwin as of December, 2016, but with a qualification that it works only for remote commands and not for connections that require a pseudo terminal.描述了截至 2016 年 12 月在 Cygwin 下部分实现的 ControlMaster/ControlPersist 的使用,但其限定条件是它仅适用于远程命令,不适用于需要伪终端的连接。

While this answer was not confirmed under Cygwin, per se, it was validated as true for MSYS2 (based on Cygwin).虽然这个答案本身没有在 Cygwin 下得到证实,但它在 MSYS2(基于 Cygwin)中被证实是正确的。 openssh under MSYS2 supports ControlMaster/ControlPersist connections for remote commands, but not for interactive sessions. MSYS2 下的 openssh 支持远程命令的 ControlMaster/ControlPersist 连接,但不支持交互式会话。

$ cygcheck -V | head -3
cygcheck (msys) 3.0.7
System Checker for Msys
Copyright (C) 1998 - 2019 Cygwin Authors

$ ssh -V
OpenSSH_8.1p1, OpenSSL 1.1.1d  10 Sep 2019

$ pacman -Qi openssh
Name            : openssh
Version         : 8.1p1-1
Description     : Free version of the SSH connectivity tools
Architecture    : i686
URL             : https://www.openssh.com/portable.html
Licenses        : custom:BSD
Groups          : net-utils
Provides        : None
Depends On      : heimdal  libedit  libcrypt  openssl
Optional Deps   : None
Required By     : sshpass
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 4.55 MiB
Packager        : Alexey Pavlov <alexpux@gmail.com>
Build Date      : Mon, Oct 14, 2019 1:12:28 AM
Install Date    : Thu, Oct 24, 2019 8:38:48 PM
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

The following errors occur when running ssh without a remote command specified:在没有指定远程命令的情况下运行ssh时会发生以下错误:

mm_send_fd: sendmsg(2): Broken pipe
mux_client_request_session: send fds failed

With remote commands specified, the errors do not occur.指定远程命令后,不会发生错误。

No, not Cygwin nor OpenSSH nor Dropbear - but there is one another lightweight ssh multiplexing option on Windows: PuTTY supports "Share SSH connections if possible"不,不是 Cygwin、OpenSSH 或 Dropbear - 但在 Windows 上还有另一种轻量级 ssh 多路复用选项:PuTTY 支持“如果可能,共享 SSH 连接”

在此处输入图片说明

If you need a console version, I would suggest working your way down this list: https://en.wikipedia.org/wiki/Comparison_of_SSH_clients#Platform如果您需要控制台版本,我建议您按照以下方式工作: https : //en.wikipedia.org/wiki/Comparison_of_SSH_clients#Platform

SSH Multiplexing lowers the initial connection latency substantially because the initial handshake has already taken place. SSH 多路复用大大降低了初始连接延迟,因为初始握手已经发生。 Technically it should be possible - and useful - to implement full UNIX socket functionality on Cygwin - but doing it properly would somewhat of an undertaking.从技术上讲,在 Cygwin 上实现完整的 UNIX 套接字功能应该是可能的——而且是有用的——但正确地做到这一点会有些困难。 Some of the functionality is there, but it's unlikely to be secure and it's a hack, see What mechanism is used by MSYS/Cygwin to emulate Unix domain sockets?有些功能是存在的,但它不太可能是安全的,它是一个黑客,请参阅MSYS/Cygwin 使用什么机制来模拟 Unix 域套接字?

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

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