通过 SSH 重新生成证书
通过 SSH 以 Root 用户登录到 ESXi 主机的命令行,使用以下命令重新生成新的 SSL 证书。
1
2
| /sbin/generate-certificates
/etc/init.d/hostd restart && /etc/init.d/vpxa restart
|

通过 PowerShell 脚本重新生成证书
如果你不想一个一个 SSH 登录到 ESXi 主机,也可以运行下面的 Powershell 脚本(管理员身份)来重新生成新的 SSL 证书。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| # Install the Posh-SSH module if not already installed
Install-Module -Name Posh-SSH -Force
# Define the ESXi host details
$esxiHost = "192.168.32.62"
$username = "root"
$password = "Vcf5@password"
# Convert the password to a secure string
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
# Create the credential object
$credential = New-Object System.Management.Automation.PSCredential ($username, $securePassword)
# Establish the SSH session
$session = New-SSHSession -ComputerName $esxiHost -Credential $credential
# Run the command to regenerate certificates
Invoke-SSHCommand -SessionId $session.SessionId -Command '/sbin/generate-certificates'
# Restart the hostd service
Invoke-SSHCommand -SessionId $session.SessionId -Command '/etc/init.d/hostd restart && /etc/init.d/vpxa restart'
# Close the SSH session
Remove-SSHSession -SessionId $session.SessionId
|
