Posts

Showing posts with the label SSH

How to use SSH and SCP with VCSA

I was replacing some vCenter Server Appliance (VCSA) self-signed certificates with signed certs from an Active Directory Certificate Authority and I came across a minor issue that I wanted to document here.  I was using the /usr/lib/vmware-vmca/bin/certificate-manager tool to generate the CSR, and then PSCP to download the CSR and hand it off to the security team. When I first tried to use pscp to get the file, I encountered an error that I hadn't seen before: Fatal: Received unexpected end-of-file from server Some quick googling didn't turn up any hits on this issue, but I thought of something as I was poking around.  When I connected to the VCSA via SSH, it didn't drop me to a BASH shell until I did the usual "shell.set --enabled True" "shell" operation that it prompts you with.  Since PSCP (and SCP in general) is just establishing an SSH connection to the host and then doing a copy command, I figured that my issue was probably that the default...

Enable SSH on All ESXi Servers

Earlier, I published a quick note about basically using SSH from one ESXi host to manipulate settings across all ESXi hosts in the environment.  I've realized that it might be helpful if I include this note, around how I easily turn SSH on or off across an arbitrary number of ESXi hosts in the environment. This script is super basic - run it after connecting your powerCLI session to whatever vCenter servers you're interested in.  Then, pass it the "-h" option and a regular expression that matches the hosts that you want it to manipulate (such as *esx1* or a specific hostname or even just *).  That's it; it'll turn on the SSH service on all of those hosts, which should open the required firewall ports automatically and everything will just work. Turning SSH off again when you're done is just as simple.  Use the command the same way, but with the "-o" switch... and now the script will sweep through, turning SSH off for all hosts that match ...

Quick and Easy Datastore Usage Discovery

Have you ever had a full datastore and needed to easily discover which folder was the main culprit?  I’m sure that there are a thousand ways to do this, but one easy one is available from the ESXi host command line.  Either pull up the local console (with the local Shell enabled) or open an SSH session remotely (I know, we’re not supposed to do that anymore!).  Then, navigate to the datastore that you wish to examine with a command like: cd /vmfs/volumes/MyDatastore Once you’re on the datastore, use the “du” command to display disk usage.  If you use the command by itself, it will recursively display the disk usage of all folders/subfolders from your current location in kilobytes.  While that’s useful, it’s not the most user friendly thing in the world.  Instead, I like to use this command: du –m –d 1 That will display the disk usage in megabytes (it would be nice if it had a gigabytes option, but oh well) and will only display the total s...