Wednesday, November 16, 2011

SSH into ESXi 5 host using public key

Just a little follow up on my previous post.

If you want to enable OpenSSH Public Key Authentication on your ESXi 5 host, append contents of your public key to /etc/ssh/keys-USERNAME/authorized_keys file instead of usual ~/.ssh/authorized_keys file.

For example, to enable public key logins as root user, do the following:
cat ~/.ssh/ | ssh 'cat >> /etc/ssh/keys-root/authorized_keys'

Obviously, SSH server needs to be enabled on the ESXi host before you can do that. As I mentioned in my ESXi 5 installation write up, starting with vSphere 5 vSphere 4.1 you can easily enable SSH via ESXi's Direct Console User Interface (DCUI) or vSphere Client.