【问题标题】:TeamCity Remote Powershell Access Denied SuddenlyTeamCity 远程 Powershell 访问突然被拒绝
【发布时间】:2023-03-25 13:55:02
【问题描述】:

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

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

我作为远程服务器上的Adminstrator 用户在管理员 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-&lt;some stuff&gt;\administrator 的响应很好。但是,当我在 TeamCity 构建步骤中执行远程 Powersehll 命令时,我得到一个非常丑陋的 Connecting to remote server &lt;subdomain.domain.com&gt; failed with the following error message : Access is denied.

奇怪的是,这在两天前有效,我有几个构建能够完成所有远程操作。从今天早上开始,它就停止工作了——噗!

如果我伪造凭据,我会收到不正确的用户名/密码错误,因此它肯定会到达服务器。

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

[bool](Test-WSMan)

在远程服务器上,我得到了True 返回,但如果我在构建服务器上使用-ComputerName &lt;subdomain.domain.com&gt; 运行相同的命令,我得到
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】:

    经过更多研究和一些帮助,我被建议调整 TeamCity Build AgentTeamCity Server 服务。这些需要Log On As User 而不是Local System。我无法解释我以前的设置是如何工作的。我遇到的Access is denied错误与上面提到的Remote Powershell配置无关。

    【讨论】:

      猜你喜欢
      • 2017-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-28
      • 1970-01-01
      • 2017-10-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多