Many enterprises create and distribute their own public-private key pairs for authentication.

Use the following code as a guideline.

  1. In your local environment, obtain or generate your public-private key pair.

    If you need it, here's some background on generating key pairs in Linux and Windows.

    For now, just generate and save the keys locally.

  2. In vRealize Automation Cloud Assembly, before provisioning, add remoteAccess properties to the cloud template as shown in the example.

    The sshKey includes the long alphanumeric found within the public key file key-name.pub.

    The username is optional and gets created for you to log in with. If you omit it, the system generates a random ID as the username.

    Example:

    type: Cloud.Machine
    properties:
      name: our-vm1
      image: Linux18
      flavor: small
      remoteAccess:
        authentication: publicPrivateKey
        sshKey: ssh-rsa Iq+5aQgBP3ZNT4o1baP5Ii+dstIcowRRkyobbfpA1mj9tslf qGxvU66PX9IeZax5hZvNWFgjw6ag+ZlzndOLhVdVoW49f274/mIRild7UUW... 
        username: testuser
    
  3. In vRealize Automation Cloud Assembly, provision the machine from its cloud template, and bring it to a started-up state.
  4. Using the cloud vendor client, access the provisioned machine.
  5. Add the public key file to the home folder on the machine. Use the key that you specified in remoteAccess.sshKey.
  6. Verify that the private key file counterpart is present on your local machine.

    The key is typically /home/username/.ssh/key-name with no .pub extension.

  7. Open a remote SSH session, and connect to the provisioned machine.

    ssh -i key-name user-name@machine-ip