Getting a root shell over SSH
Nearly every recipe in chapters 1 and 2 runs commands as root on the appliance: vracli, kubectl, deploy.sh. From 9.1.1 you no longer log in as root to do that. You SSH in as vmware-system-user and switch to root with sudo . This recipe shows that login, turns SSH on and off, and keeps it tidy. Every other recipe that says “as root” means this.
Getting ready
- A standalone appliance deployed as in recipe 1.2.
- The password of
vmware-system-user, and the passwordsudoasks for. - Access to the appliance’s VM console in the vSphere Client, for the first time, when SSH may still be off.
vmware-system-user, then sudo su -), and the same login is reported for 9.1.1 Orchestrator appliances, but it hasn’t been tried in this book’s lab yet. Broadcom’s VCF 9.1 account list still shows only root and admin for a standalone Orchestrator. On a fresh 9.1.1 OVA deployment, record where the vmware-system-user password is set (its own field on Customize template, or the root password), and which password sudo su - asks for.How to do it
Log in and become root
- From your workstation, log in as
vmware-system-user:
ssh vmware-system-user@vco01.vmw.labIf the connection is refused, SSH is off. Turn it on from the console first (steps 4 to 6), then come back.
- Switch to
root:
sudo su -- Check that you’re
rootand that the appliance answers:
whoami # rootvracli vro infoType exit twice when you’re done: once to leave the root shell, once to close the SSH session.
Turn SSH on from the console
- In the vSphere Client, select the appliance VM (
vco01) and click Launch Web Console. - Log in at the console’s prompt as
vmware-system-userand runsudo su -, as in step 2. - Turn SSH on:
/usr/bin/toggle-ssh enablevSphere web console of vco01, logged in as vmware-system-user and switched to root with sudo su -, after running /usr/bin/toggle-ssh enable, showing the command's output.
Turn SSH off again
- When you’ve finished, turn SSH off. You can do this over SSH; your current session stays open until you log out:
/usr/bin/toggle-ssh disable- Log out, and try
ssh vmware-system-user@vco01.vmw.labagain. The connection should now be refused.
How it works
Why not root? Logging in as one shared administrator account gives anyone with that password full control and leaves no trace of who did what. With a named login account and sudo, root access is a separate, logged step. Broadcom gives the same reason for the VCF Automation appliance, where direct root login over SSH is turned off by default (KB 422955). root still exists and still owns everything; you just reach it through sudo.
sudo su - or sudo per command. sudo su - opens a full root login shell, with root’s environment and home folder, which is what the commands in this book expect. For a single command you can also prefix it: sudo vracli vro info. Keep to one style in a runbook, so that nobody wonders which user a command ran as.
SSH itself. The appliance runs a normal OpenSSH server on Photon OS. toggle-ssh is a small script shipped on the appliance that starts or stops that service and sets whether it starts at boot, so the setting survives a reboot. It’s the same switch as the SSH option on the Customize template page when you deploy the OVA (recipe 1.2, step 10). Ticking that box just saves you steps 4 to 6.
/usr/bin/toggle-ssh enable and disable commands come from the Orchestrator 8.x documentation; the 9.1 page has the same title. Confirm the script exists on a 9.1.1 appliance and note its exact output for Figure 2.1, and check that enable survives a reboot.https://appliance:5480, tick SSH service enabled, and log in as root.vmware-system-user and run sudo su -. Turn SSH on or off with toggle-ssh, or tick the option when you deploy.There's more
Copying files to the appliance. scp logs in the same way, so copy files as vmware-system-user into its home folder, then move them as root:
scp vco01-chain.pem vmware-system-user@vco01.vmw.lab:~mv /home/vmware-system-user/vco01-chain.pem /root/Use a key instead of a password. Copy your public key to vmware-system-user once SSH is on, and you won’t need its password for every login or scp. sudo still asks for its own password:
ssh-copy-id vmware-system-user@vco01.vmw.labHarden what you keep. If your security team wants SSH left on, you can still tighten it. The SSH server reads /etc/ssh/sshd_config as usual, so you can remove ciphers and MACs your policy doesn’t allow. Restart the service afterwards with systemctl restart sshd, and keep the VM console open while you test, in case you lock yourself out. Don’t turn root login back on: it undoes the point of the change.
/etc/ssh/sshd_config may be overwritten by an appliance upgrade. Check whether a custom cipher list survives an upgrade from 9.1.1 to 9.1.2.Clusters. In a three-node cluster (recipe 2.4), SSH and vmware-system-user are per node. Turn SSH on, and log in, on each appliance you need to reach.
No console access either? If you can reach neither SSH nor the VM console, you can’t run any vracli command. Ask your vSphere team for console access before you start a maintenance window.
See also
- 1.8 Configuring Orchestrator from the command line, for what to do once you’re in.
- 2.2 Replacing the appliance certificate, which copies a file to the appliance with
scp. - Broadcom KB 422955: Direct root access is restricted in VCF Automation, the same
vmware-system-userandsudo su -login on the VCF Automation appliance. - Broadcom TechDocs (VCF 9.1): Accounts in VMware Cloud Foundation, and Activate or Deactivate SSH Access to VCF Operations Orchestrator under Workload Orchestration > Administering VCF Operations Orchestrator > Initial VCF Operations Orchestrator Setup.
