VMware Cloud Community
sukumarr
Contributor
Contributor

How to Copy a File from vRO to guest using ssh key

Hello,

I want to copy a file from vRO instance (inbuilt in vRA) to the guest VM using the ssh key (in the scriptable task). I don't want to keep the password in my flow because, we regularly rotate the password.

Please help.

Regards,

Sukumar. R.

Tags (2)
0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee

Hi,

I'm not sure if this is possible. Most guest operations use GuestAuthentication data object to pass authentication data, and looking at its documentation at http://pubs.vmware.com/vsphere-6-5/index.jsp#com.vmware.wssdk.apiref.doc/vim.vm.guest.GuestAuthentic...  I don't see a class that extends GuestAuthentication and provides support for SSH keys.

0 Kudos
Burke-
VMware Employee
VMware Employee

This is possible - using the SSH plug-in.

You must register the vRO public key with the guest first (IE: Have it already present in your template if possible).

Then, going forward you can use the SSH plug-in to copy file(s) from vRO to the guest OS via SCP using the SSH key as authentication, negating the need to keep providing a password. Unfortunately, it doesn't look like the library workflows are written to provide this particular transfer option with key based auth.. but it isn't that hard to setup.

Take a look at the SSHSession object using the API Explorer:

Establish a session using your key:

var mySSHSession = new SSHSession(host,user);

mySSHSession.connectWithIdentity("/var/lib/vco/app-server/conf/vco_key");

Transfer a file:

var result = mySSHSession.putFile(myLocalFile,remoteFilePath); // returns 0 if successful, -1 if error has occurred

// add logging/debugging as needed

// close out the session:

mySSHSession.disconnect();

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos