Windows 机器中的 TFS SSH 任务失败

TFS SSH task in Windows Machine failed

我试图连接一台 Windows 机器,它存在于我们的 TFS 2018.3 之外的另一个域中。

我添加了 "SSH" 任务,并使用远程机器 IP、用户名和密码创建了新的 SSH 端点,没有 私钥。我在 SSH 的远程机器访问中配置了这个用户名和密码。

在SSH任务中,我配置了一个简单的shell命令:ls.

TFS 代理成功连接计算机但失败并出现此错误:

Unable to execute command or shell on remote system: Failed to Execute process.

完整日志:

2019-08-15T13:22:54.1491966Z Trying to setup SSH connection to ********@myserverinanotherdomain:22

2019-08-15T13:22:54.4085564Z Successfully connected.

2019-08-15T13:22:54.8120684Z tr -d '5' <"./sshscript_1565875374136" > "./sshscript_1565875374136._unix"

2019-08-15T13:22:54.8121422Z Unable to execute command or shell on remote system: Failed to Execute process.

2019-08-15T13:22:54.8121745Z

2019-08-15T13:22:54.8180230Z ##[error]Command tr -d '5' <"./sshscript_1565875374136" > "./sshscript_1565875374136._unix" exited with code 4294967295.

我想是因为它是 Windows 机器,我尝试执行 shell 脚本。如果我将安装Git bash,例如,它可以帮助吗?

SSh 任务是否只支持 Linux 台机器?如果是,我如何连接存在于另一个域中的机器?

SSH 作为一种通信协议与 OS 无关。它不是 Linux 具体的。但是在 windows machine/build 代理上使用 SSH 任务似乎有限制。在这里看看这个类似的问题:Not able to run bash script from windows using vsts.

我还没有找到明确声明 Windows 机器不支持 SSh 任务的文档。但是我发现了一个也使用 SSH 的任务——Copy Files Over SSH 任务。而根据官方Q&A link:

Is this task supported for target machines running operating systems other than Linux?

This task is intended for target machines running Linux.

  • For copying files to a macOS machine, this task may be used, but authenticating with a password is not supported.
  • For copying files to a Windows machine, consider using Windows Machine File Copy.

而不是 SSH。您应该能够在构建服务器上和输入凭据时使用本地帐户。该帐户必须与其他域中的帐户具有相同的密码。在其他工作中,确保构建代理上 运行 的构建帐户能够连接另一个域。

还要确保域之间存在信任关系。