How to Setup SSH key for VMware ESXi
1. Generate SSH Key (from your workstation)
On your Linux/Mac machine (or Windows with Git Bash/WSL/PowerShell):
ssh-keygen -t rsa -b 4096
- Save it in
~/.ssh/id_rsa(default). - This creates:
id_rsa→ private key (keep safe, use this key to SSH to ESXi server).id_rsa.pub→ public key (to copy to ESXi).
2. Enable SSH on ESXi
- Log in to the ESXi Web UI (https://<esxi-host-ip>/ui).
- Go to Host → Actions → Services → Enable Secure Shell (SSH).
(Or enable via DCUI: Troubleshooting Options → Enable SSH)

3. Create the .ssh Directory on ESXi
SSH into your ESXi host with your password once:
ssh root@<esxi-host-ip>Then run:
mkdir -p /etc/ssh/keys-rootExit ESXi SSH session:
exit4. Copy Public Key to ESXi
From your workstation (Ensure you have existed VMware SSH):
scp ~/.ssh/id_rsa.pub root@<esxi-host-ip>:/etc/ssh/keys-root/authorized_keys
On the ESXi host:
chmod 600 /etc/ssh/keys-root/authorized_keys5. Test Connection
From your workstation:
ssh root@<esxi-host-ip>You should be logged in without a password prompt.
6. Persist Across Reboots
ESXi does not persist custom files in /etc and SSH connection after reboot. To make sure the authorized_keys file survives:
- Create a startup script:
vi /etc/rc.local.d/local.sh- Add this before the final
exit 0line, hit 'i' to insert the text, ':wq' to save change, ':q!' exist without save:
vim-cmd hostsvc/enable_ssh
cp /store/authorized_keys /etc/ssh/keys-root/authorized_keys
chmod 600 /etc/ssh/keys-root/authorized_keys
- Save your public key copy into
/store/authorized_keys(which is persistent):
mkdir -p /store
cp /etc/ssh/keys-root/authorized_keys /store/authorized_keys- Make the script executable:
chmod +x /etc/rc.local.d/local.sh- Reset VMware and Test SSH Login From Workstation:
ssh root@<esxi-host-ip>If you found this guide helpful, consider supporting me!