Cygwin OpenSSH服务器在PHP发出第一个命令后不响应(使用phpseclib)

Cygwin OpenSSH服务器在PHP发出第一个命令后不响应(使用phpseclib),ssh,cygwin,openssh,phpseclib,ssh2-exec,Ssh,Cygwin,Openssh,Phpseclib,Ssh2 Exec,我让cygwin和sshd工作得很好。而且使用腻子时根本没有问题。即使对于多个命令,它也会按预期响应。但是当使用phpseclib时,只会收到第一个命令的响应。后续命令将给出一个空白回复。 这是我试图执行的脚本- 那是。。。奇怪的FWIW这似乎不是phpseclib的问题,而是服务器的问题。如果你看一下日志,你会看到两个问题,我找到了解决方案- 问题的原因是,在基于windows的系统中,在执行新命令之前会调用setuid。对于第一个命令,其初始设置为,因此没有问题。但是,随后的调用会导致尝试

我让cygwin和sshd工作得很好。而且使用腻子时根本没有问题。即使对于多个命令,它也会按预期响应。但是当使用phpseclib时,只会收到第一个命令的响应。后续命令将给出一个空白回复。 这是我试图执行的脚本-


那是。。。奇怪的FWIW这似乎不是phpseclib的问题,而是服务器的问题。如果你看一下日志,你会看到两个问题,我找到了解决方案- 问题的原因是,在基于windows的系统中,在执行新命令之前会调用setuid。对于第一个命令,其初始设置为,因此没有问题。但是,随后的调用会导致尝试重新分配,并导致失败,openssh将无法执行此操作。在ssh主机配置脚本中已经解释了这一点-

*** Info: You appear to be running Windows XP 64bit, Windows 2003 Server,
*** Info: or later.  On these systems, it's not possible to use the LocalSystem
*** Info: account for services that can change the user id without an
*** Info: explicit password (such as passwordless logins [e.g. public key
*** Info: authentication] via sshd).

*** Info: If you want to enable that functionality, it's required to create
*** Info: a new account with special privileges (unless a similar account
*** Info: already exists). This account is then used to run these special
*** Info: servers.
为了解决这个问题,您需要创建脚本试图创建的特权用户帐户,并确保在脚本末尾显示-

*** Info: The sshd service has been installed under the 'cyg_server'
*** Info: account.  To start the service now, call `net start sshd' or
*** Info: `cygrunsrv -S sshd'.  Otherwise, it will start automatically
*** Info: after the next reboot.
任何表明该帐户未找到且默认为“系统”帐户的消息都将导致该问题。在这种情况下,请确保passwd文件是最新的,并且包含新用户

当您启动Windows服务管理器并检查CYGWIN sshd服务的属性时,在“登录”选项卡下,需要说明它正在使用新创建的特权帐户,而不是本地帐户


另外,请验证在“组策略编辑器->安全设置->本地策略->用户权限分配”下,新用户帐户需要具有创建令牌对象和作为操作系统一部分的权限。

您好,谢谢您提供的信息性回复。不仅仅是nproc。无论第一或第二命令是什么,情况都是一样的。我在不同的盒子上尝试了相同的设置,但仍然面临相同的问题。我试着从油灰和一切都很好,当使用油灰。如何记录/诊断sv侧的问题。这是一个安装了cygwin和openssh的windows机箱。但我希望日志也能起到类似的作用。
  byte      SSH_MSG_CHANNEL_REQUEST
  uint32    recipient channel
  string    "exit-status"
  boolean   FALSE
  uint32    exit_status
*** Info: You appear to be running Windows XP 64bit, Windows 2003 Server,
*** Info: or later.  On these systems, it's not possible to use the LocalSystem
*** Info: account for services that can change the user id without an
*** Info: explicit password (such as passwordless logins [e.g. public key
*** Info: authentication] via sshd).

*** Info: If you want to enable that functionality, it's required to create
*** Info: a new account with special privileges (unless a similar account
*** Info: already exists). This account is then used to run these special
*** Info: servers.
*** Info: The sshd service has been installed under the 'cyg_server'
*** Info: account.  To start the service now, call `net start sshd' or
*** Info: `cygrunsrv -S sshd'.  Otherwise, it will start automatically
*** Info: after the next reboot.