hicli is available in an API bundle from the Cryptographic Security Platform Vault webGUI:
- Log into the Cryptographic Security Platform Vault for VM Encryption using an account with Cloud Admin privileges.
- In the top menu bar, click Workloads.
- Select Actions > Download Policy Agent.
- From the Available Downloads dialog box, download the
hcs-api-10.5.3-buildnum.tgzfile, wherebuildnumis the build number for the release you are installing. - Copy the
tgzfile to the VM on which you want to install the API. Navigate to a directory where you want to install the package and untar it as follows:
$ cd ~ $ tar xvfz hcs-api-10.5.3-buildnum.tgz x hcs-api/ x hcs-api/hclcomm.py x hcs-api/kpsapi.py x hcs-api/docopt.py x hcs-api/hiclihiclineeds the Pythonrequestsmodule, and to manage Windows VMs, it also needs thewinrmmodule. Install these modules:$ pip install requests $ pip install pywinrm
Set up
PYTHONPATHto point to the new directory and modify yourPATHso that the shell can reference thehicliprogram. For example, if the install location is/Users/spate, the environment variables need to be set up as follows:$ export PYTHONPATH=$PYTHONPATH:/Users/spate/hcs-api $ export PATH=$PATH:/Users/spate/hcs-api
Note: If your python installation only includes a python command and not a python3 command, then do one of the following:
Edit the first line of hicli from
#!/usr/bin/env python3 to #!/usr/bin/env python.Define an alias similar to
hicli='python /Users/<user_name>/hcs-api/hicli'using your install location.
Set up a configuration file named
~/.hicli/hicli.cfgthat contains information about the virtual machines to be managed. The following example shows a configuration file with two Linux VMs and one Windows VM.Notes:
- The number and location of curly brackets is important. Make sure your configuration file looks like the example below.
- If the platform is not specified it defaults to
"linux". - A password is required for Windows platforms to connect over winrm.
- By default, the
hicli.cfgfile is used to resolve VM names. If no entries are found, DNS is used to resolve the VM names. - On Linux, you can run
hiclicommands asrootor as asudouser. If you specify asudouser, you also specify a password if thesudouser requires one. On Windows, you can runhicliwith any Windows account that has Administrator privileges.
The following example shows a
hicli.cfgfile with three Linux VMs and one Windows VM. The Linux ubuntu10.04 VM uses the standardrootaccount, the ubuntu12.10 VM uses thesudouserspatewith the passwordDogDays123!, and the rhel73 VM uses the passwordlesssudouserjsmith. The Windows VM uses theAdministratoraccount with the passwordXYZ@123.{"cvmlist": {"ubuntu10.04": {"host":"192.168.140.129",
"port":"22",
"user":"root"
},
"ubuntu12.10": {"host":"192.168.140.130",
"port":"22",
"user":"spate",
"sudo_password" : "DogDays123!"
},
"rhel73": {"host":"192.168.140.131",
"port":"22",
"user":"jsmith"
},
"Windows2012r2": {"host":"192.168.140.132",
"user":"Administrator",
"password":"XYZ@123",
"platform": "windows"
}
}
}
If you want to manage another VM with
hicli, just add that entry to thecfgfile.{"cvmlist": {"ubuntu10.04": {"host":"192.168.140.129",
"port":"22",
"user":"root"
},
"ubuntu12.10": {"host":"192.168.140.130",
"port":"22",
"user":"spate",
"sudo-password" : "DogDays123!"
},
"rhel73": {"host":"192.168.140.131",
"port":"22",
"user":"jsmith"
},
"Windows2012r2": {"host":"192.168.140.132",
"user":"Administrator",
"password":"XYZ@123",
"platform": "windows"
},
"ubuntu13.04": {"host":"192.168.140.133",
"port":"22",
"user":"root"
}
}
}
- To verify the installation, run the
hiclicommand and you should see a comprehensive listing of the command and its options. To set up SSH communication on each Linux host, generate a key pair on the API server and copy the public key to each VM on which you want to run API commands. The public key should be appended to the
authorized_keysfile for eitherrootor the sudo user you specified in thehicli.cfgfile. (For the Windows VM you would use WinRM.)The following example uses
ssh-keygenon the API server to generate the key pair and then usesssh-copy-idto send the public key to the Linux VMs we added to thehicli.cfgfile above.api# cd ~/.ssh api# ssh-keygen -t dsa api# ssh-copy-id id_dsa.pub root@192.168.140.129 api# ssh-copy-id id_dsa.pub spate@192.168.140.130 api# ssh-copy-id id_dsa.pub jsmith@192.168.140.131 api# ssh-copy-id id_dsa.pub root@192.168.140.133
After you copy the public key to the VM, make sure that, on each VM:
- You enable root or sudo user login over SSH to the VM. If you are using a passwordless sudo user, you need to set up passwordless SSH access for that user using the pub.
- You turn off SSH warnings.
To test that SSH access is working between your API server and your VM, issue a test command over SSH. For example, you can use SSH to query the hostname on the VM:
$ ssh root@192.168.140.129 hostname ubuntu10.04