如何使用证书指纹连接 PSSession?

How to connect with PSSession using for Auth a Certificate ThumbPrint?

我在 Windows Server 2012 R2 机器(机器 1)上,我想通过 PSSession 连接到另一台机器(机器 2)。 对于身份验证,我想使用 CertificateThumbprint(这可能吗?)。 证书存放在机器 2 上。 为此,我使用以下命令:

New-PSSession -Computername 172.16.17.51 -CertificateThumbprint cd4eeae600ac7f452dfsflg32fs3r4

但是我得到一个错误,他找不到证书。 我必须使用哪个证书?或者我需要另一个命令吗?

提前致谢

您需要将证书存储在机器 1 和机器 2 上。当您尝试连接时,脚本将在本地证书存储中查找,而不是在您连接到的机器中查找。

安装证书时,请确保再次检查指纹,因为这可能会在机器之间发生变化。

我会将证书放入 'Trusted Root Cert Authorities' 和 'Personal' 下的本地机器存储中,完成后您可以使用以下命令获取指纹 dir Cert:\LocalMachine\My\

为此,您必须为 winrm 启用证书身份验证,然后将证书添加到 winrm certMapping table。如果我没记错的话,你需要在你连接的机器上为你的证书设置一个 https 监听器。您可能还需要参数 -useSSL on New-PSSession.

winrm create winrm/config/Listener?Address=IP:<Enter your IP Address Here>+Transport=HTTPS @{Hostname="<FQDN as it appears in the certifcate>";CertificateThumbprint="<Hexidecimal thumbprint certificate>"}