Skip to content

Using Shared Credentials

Michael Daines edited this page Sep 15, 2013 · 6 revisions

Here's a walk-through of how to use Shared Credentials, as of version 0.5.1 of the gem.

In order to keep verbosity to a minimum, all of the examples assume that the Nexpose module has been included:

include Nexpose

As with all uses of the gem, in order to interact with a Nexpose console you will need an active, valid connection. The following line can be assumed for all code below:

nsc = Connection.new('10.2.0.1', 'nxadmin', 'secret-password')
nsc.login

List All Current Shared Credentials

This will get an Array of all existing credentials. This is just a summary of each credential

nsc.shared_credentials

Modify the Configuration of an Existing Credential

Load in the configuration details of a credential. This can be used to modify the existing cred.

Note that when password information has already been saved, it is not transfered as part of this request. If the credential is saved without password details, they will be preserved on the console. You should only set password information if it is changing.

Here we add site 42 to the list of sites this shared credential is applied to.

cred = SharedCredential.load(nsc, 13)
cred.sites << 42
cred.save(nsc)

Create a New Shared Credential