TeamCity远程Powershell突然被拒绝

问题描述 投票:3回答:1

免责声明:我不是DevOps家伙,所以请原谅任何无知。我正在学习这些东西,以加深我的理解。

我已在Windows Server 2019实例上启用了远程Powershell,以便在从构建服务器(也是Windows Server 2019)部署文件期间停止/启动计划的任务。

我以远程服务器上的Adminstrator用户身份在Administrator Powershell中执行了以下步骤:1.启用RSRemoting。2.删除现有的侦听器。3.创建自签名证书并导出到crt文件。

$Cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName "<subdomain.domain.com>"
  1. 创建监听器。
  2. 创建防火墙规则以允许安全PSRemoting并禁用不安全的连接。
  3. 将证书复制到构建服务器。
  4. 在构建服务器上导入证书。

[从构建服务器,我已经在Powershell中使用以下命令测试了配置:

$username = 'Administrator'
$pass = ConvertTo-SecureString -string '<password here>' -AsPlainText -Force
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $pass
Invoke-Command -ComputerName <subdomain.domain.com> -UseSSL -ScriptBlock {whoami} -Credential $cred

[win-<some stuff>\administrator的响应很好。但是,当我从TeamCity构建步骤中执行远程Powersehll命令时,会出现一个非常难看的Connecting to remote server <subdomain.domain.com> failed with the following error message : Access is denied.

奇怪的是,这是两天前完成的工作,我拥有一些能够完成所有远程操作的构建。从今天早上开始,它刚刚停止工作-of!

如果我篡改了凭据,则会收到错误的用户名/密码错误,因此肯定可以到达服务器。

另一个有趣的发现是,如果我跑步

[bool](Test-WSMan)

在远程服务器上,我得到True返回,但是如果在构建服务器上用-ComputerName <subdomain.domain.com>运行相同的命令,我得到WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles limits access to remote computers within the same local subnet.返回。远程主机和构建服务器均以默认Administrator身份登录。

有什么想法吗?

powershell teamcity remote-access
1个回答
1
投票

[经过更多研究并提出了一些建议后,建议我调整TeamCity Build AgentTeamCity Server服务。这些需要Log On AsUser而不是Local System。我无法解释以前的设置如何工作。我遇到的Access is denied错误与上述远程Powershell配置无关。

© www.soinside.com 2019 - 2024. All rights reserved.