3

I have close to 70 ESX hosts that need to have the root SSH keys added to them. Is there a way to do this through vsphere or powercli, or will I have to manually SSH into each box and add the line to each file?

EGr
  • 575
  • 3
  • 12
  • 29

3 Answers3

0

I have a large number of ESXi hosts as well... We don't do key exchange to the hosts, as most of your real work should be accomplished at another layer (API, vCenter, PowerCLI, etc.)

Why do you need to have keys added? ESXi isn't a general-purpose operating system, so I'd hope that hypervisor access is infrequent.

If you absolutely require this, though, you can use an expect script from a Linux host or build it into the build/imaging process. Since VMware ESXi hosts can be kickstarted, use this hint to get the key into future builds.

ewwhite
  • 194,921
  • 91
  • 434
  • 799
0

You can update the file via the vSphere CLI (the Perl-based one, not PowerCLI!) by running

vifs.pl –-server <hostname> –-username <username> –-put ssh_root_authorized_keys /host/ssh_root_authorized_keys

This will upload a local file names ssh_root_authorized_keys to the host.

VFrontDe
  • 1,478
  • 8
  • 11
0

You can use this script to add keys and to automate ssh to every host:

http://goo.gl/Pu8VBF

Follow the url to have a look on the perl script and you can modify it with this line to add keys: touch ~/.ssh/authorized_keys && cat - >> ~/.ssh/authorized_keys"

Zeeshan
  • 351
  • 1
  • 5