Failed to validate config file /etc/ssh/sshd_config.tmp.######
esxcli system ssh server config set -k loglevel -v debug OR localcli system ssh server config set -k loglevel -v debugesxcli system ssh server config set -k permitrootlogin -v no OR localcli system ssh server config set -k permitrootlogin -v no/var/run/log/localcli.log are as follows
In(14) localcli[210####]: Util: ForkExec(/usr/lib/vmware/openssh/bin/sshd   -t -f /etc/ssh/sshd_config.tmp.EYc###) 2101###
Er(11) localcli[210####]: SshServerConfigImpl: Validation failed : /etc/ssh/sshd_config.tmp.EYc###
Er(11) localcli[210####]: SshServerConfigImpl: Failed to save config: Failed to validate config file /etc/ssh/sshd_config.tmp.EYc###
/var/run/log/hostd.log are as follows 
Hostd[21043##]: [Originator@6876 sub=Libs opID=esxcli-b9-#### sid=5261#### user=root] Util: ForkExec(/usr/lib/vmware/openssh/bin/sshd  ++group=hostd-tmp,mem=120 -t -f /etc/ssh/sshd_config.tmp.MCZ### ) 2104###
Hostd[21043##]: [Originator@6876 sub=Libs opID=esxcli-b9-#### sid=5261#### user=root] SshServerConfigImpl: Validation failed : /etc/ssh/sshd_config.tmp.MCZ###
Hostd[21043##]: [Originator@6876 sub=Libs opID=esxcli-b9-#### sid=5261#### user=root] SshServerConfigImpl: Failed to save config: Failed to validate config file /etc/ssh/sshd_config.tmp.MCZ###
Hostd[21043##]: [Originator@6876 sub=Solo.VmwareCLI opID=esxcli-b9-#### sid=5261#### user=root] Dispatch system.ssh.server.config.set done
Hostd[21043##]: [Originator@6876 sub=Solo.VmwareCLI opID=esxcli-b9-#### sid=5261#### user=root] Dispatch system.ssh.server.config.set failed
Hostd[21043##]: [Originator@6876 sub=AdapterServer opID=esxcli-b9-#### sid=5261#### user=root] AdapterServer caught exception; <<5261####-####-####-e04e-7b50a1######, <TCP '127.0.0.1 : 8307'>, <TCP '127.0.0.1 : 15115'>>, h
Hostd[21042##]: --> )
Hostd[21042##]: --> [context]zKq7#####jYA[/context]
Hostd[21043##]: [Originator@6876 sub=Solo.Vmomi opID=esxcli-b9-#### sid=5261#### user=root] Activation finished; <<5261####-####-####-e04e-7b50a1######, <TCP '127.0.0.1 : 8307'>, <TCP '127.0.0.1 : 15115'>>, ha-cli-handler-
Hostd[21043##]: [Originator@6876 sub=Solo.Vmomi opID=esxcli-b9-#### sid=5261#### user=root] Arg keyword:
Hostd[21042##]: --> "loglevel"
Hostd[21043##]: [Originator@6876 sub=Solo.Vmomi opID=esxcli-b9-#### sid=5261#### user=root] Arg reset:
Hostd[21042##]: --> (null)
Hostd[21043##]: [Originator@6876 sub=Solo.Vmomi opID=esxcli-b9-#### sid=5261#### user=root] Arg value:
Hostd[21042##]: --> (string) [
Hostd[21042##]: -->    "debug"
Hostd[21042##]: --> ]
Hostd[21043##]: [Originator@6876 sub=Solo.Vmomi opID=esxcli-b9-#### sid=5261#### user=root] Throw vim.EsxCLI.CLIFault
Hostd[21043##]: [Originator@6876 sub=Solo.Vmomi opID=esxcli-b9-#### sid=5261#### user=root] Result:
Hostd[21042##]: --> (vim.EsxCLI.CLIFault) {
Hostd[21042##]: -->    errMsg = (string) [
Hostd[21042##]: -->       "Failed to validate config file /etc/ssh/sshd_config.tmp.MCZ###"
Hostd[21042##]: -->    ],
Hostd[21042##]: -->    msg = "",
Hostd[21042##]: --> }
/etc/ssh/sshd_config file content - # Do not edit this file, config store overwrites it.# This file contains the Server Config for SSH.# Running from inetd.......syslogfacility authtcpkeepalive yesusepam yes......authorizedkeysfile /etc/ssh/keys-%u/authorized_keysPasswordAuthentication no
/etc/ssh/sshd_config file content - # Do not edit this file, config store overwrites it.# This file contains the Server Config for SSH.# Running from inetd.......syslogfacility authtcpkeepalive yesusepam yes......authorizedkeysfile /etc/ssh/keys-%u/authorized_keysPasswordAuthentication noUsePAM no
/etc/ssh/sshd_config files is the presence of both - lowercase parameter usepam yes in both hosts, and an additional uppercase parameter UsePAM no only in the affected host. The issue arises from conflicting SSH configuration parameters in the /etc/ssh/sshd_config file, where newer ESXi versions (vSphere 8.x and later) require the lowercase 'usepam' parameter, while older versions (vSphere 7.0 and earlier) use the uppercase 'UsePAM' parameter by default. Having both entries simultaneously causes validation failures during SSH configuration updates.To address and prevent recurrence of this issue, the following corrective actions are recommended -
cat /etc/ssh/sshd_config
# Do not edit this file, config store overwrites it.
# This file contains the Server Config for SSH.
# Running from inetd.
...
...
syslogfacility auth
tcpkeepalive yes
usepam yes
...
...
authorizedkeysfile /etc/ssh/keys-%u/authorized_keys
PasswordAuthentication no
UsePAM no
sshd_config file by executing the following command -cp /etc/ssh/sshd_config /tmp/sshd_config_bkp
vi /etc/ssh/sshd_config
Sample sshd_config file after update
# Do not edit this file, config store overwrites it.
# This file contains the Server Config for SSH.
# Running from inetd.
...
...
syslogfacility auth
tcpkeepalive yes
usepam yes
...
...
authorizedkeysfile /etc/ssh/keys-%u/authorized_keys
PasswordAuthentication no
/etc/init.d/SSH restart
esxcli system ssh server config set -k loglevel -v debug OR esxcli system ssh server config set -k permitrootlogin -v no