Last updated on Monday 28th of February 2022 08:52:48 PM

How to enable SSH on your ©ESXi host.

Using vim-cmd to enable SSH on host start up

Since ©ESXi 6.7.0 ©VMWare has decided to not switch the SSH service on, even though you might have decided to turn it on in a previous power on cycle. This means that you have to remember to switch it on again manually through the http web client every time you reboot some server.

This can be really annoying when you have to work over a remote connection through a firewall, as you might not have immediate web access to the HTML5 interface. On the other hand, the alleged security reinforcement is not quite clear, as: the SSH protocol is an industry standard and secure enough (by now), at least more secure than HTTP, which is the protocol ©ESXi enabled by default.

So, let's get to the matter. Fortunately we have the /etc/rc.local.d/ file which allows us to set some start up code and we also have the vim-cmd command, which allows us to enable the SSH shell via a shell command.

vim-cmd hostsvc/enable_ssh

So, to enable this service on startup we just have to add this line to the /etc/rc.local.d/ file. We have prepared this code snippet for your convenience, just cut and paste to your ©ESXi shell to enable the SSH protocol on start up. Just copy and paste to your shell and press enter.

sed -i '/exit 0/d' /etc/rc.local.d/
echo "vim-cmd hostsvc/enable_ssh" >> /etc/rc.local.d/ && \
echo "exit 0" >> /etc/rc.local.d/
cat /etc/rc.local.d/

(*)Make sure that you don't duplicate the vim-cmd line. The contents of '/etc/rc.local.d/' are printed

Daniel J. García Fidalgo