четверг, 20 августа 2009 г.

EMCLI Using SSH Key Credentials

Setup Example Session

Note:
The procedure shown in this example assumes that you have a firm understanding of SSH setup procedures and user and host equivalence using public private key pair using SSH.
To generate, manage, or convert SSH authentication keys, you use the SSH-keygen utility available on UNIX systems. This utility SSH-keygen tool provides different options to create with different strengths RSA keys for SSH protocol version 1 and RSA or DSA keys for use by SSH protocol version 2.
Example 13-10 Setting Up SSH key-based Authentication
$ ssh-keygen -t rsa      
The command options instruct the utility to generate SSH keys (RSA key pair).
Generating public/private rsa key pair.
Enter file in which to save the key (/home/myhome/.ssh/id_rsa):  
The path specified is the standard path to the location where SSH keys are stored ($HOME/.ssh).
Enter passphrase (empty for no passphrase)
Important: passphrase is not supported for use with SSH keys in named credentials.
Enter same passphrase again: (empty for no passphrase)
Your identification has been saved in /home/admin1/.ssh/id_rsa.
Your public key has been saved in /home/admin1/.ssh/id_rsa.pub.
The key fingerprint is:
bb:da:59:7a:fc:24:c6:9a:ee:dd:af:da:1b:1b:ed:7f admin1@myhost2170474
The ssh-regkey utility has now generated two files in the .ssh directory.
$ ls   
id_rsa  id_rsa.pub
To permit access to the host without having SSH prompt for a password, copy the public key to the authorized_keys file on that system.
$ cp id_rsa.pub  authorized_keys   
From this point, all keys listed in that file are allowed access.
Next, perform a remote logon using SSH. The system will not prompt you for a password.
$ ssh myhost  
The authenticity of host 'myhost (10.229.147.184)' can't be established.
RSA key fingerprint is de:a0:2a:d5:23:f0:8a:72:98:74:2c:6f:bf:ad:5b:2b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'myhost,10.229.147.184' (RSA) to the list of known hosts.
Last login: Mon Aug 29 16:48:45 2012 from anotherhost.example.com
$
You are now ready to add the credential to Enterprise Manager.
  1. From the Setup menu, select Security, then select Named Credentials.
  2. On the Named Credentials page, click Create. The Create Credential page displays.
  3. Enter a Credential Name. For example, SSHCRED1.
    Note: The SSHCRED1 credential set will be used in Section 13.5.2.2, "Setting Up Host Preferred Credentials Using SSH Key Credentials"
  4. Select Host from the Authenticating Target Type drop-down menu.
  5. Select SSH Key Credentials from the Credential Type drop-down menu as shown in the following figure.
    Graphic displays the SSH Credential properties.
  6. Ensure that the SSH private key/public key files have been copied to the host on which the browser is running.
  7. From the Credential Properties region, click Browse for Public Key and Private Key to upload the generated public key/private key files.
  8. Click Test and Save to verify the credentials and save them. The new named credential will appear as shown in the following figure.
Figure 13-7 Named Credential Using SSH Keys
named credential using SSH keys

13.5.2.2 Setting Up Host Preferred Credentials Using SSH Key Credentials

You can set up host preferred credentials to use SSH keys by creating a new credential set that uses the HostSSHCreds credential type. Enterprise Manager administrators then set up preferred credentials that use this credential set. Each Enterprise Manager target type can have one or more preferred credential sets of pre-defined credential types.
The following steps use EM CLI to create a host preferred credential set which supports SSH key credentials. This example assumes the existence of the named credential SSHCRED1 of type SSH Key Credentials created in the previous section.
  1. Log into EM CLI as an Enterprise Manager Super Administrator.
  2. Create a new credential set of type HostSSHCreds.
    $ emcli create_credential_set -set_name=HostSSHCredSet -target_type=host -supported_cred_types=HostSSHCreds
    
    Credential set "HostSSHCredSet" created successfully.
    
    Once the credential set is created, Enterprise Manger administrators can set up preferred credentials for this newly created credential set using either EM CLI or the Enterprise Manager console.
  3. Set up Preferred Credentials for the newly created credential set. You can use EM CLI or the Enterprise Manger console. The following EM CLI example assumes a named credential called SSHCRED1 of type SSH Key Credentials has already been created.
    $ emcli set_preferred_credential -target_type=host -target_name=myhost.oracle.com -set_name=HostSSHCredSet -credential_name=SSHCRED1
    
    Successfully set preferred credentials for target myhost.oracle.com:host.
    
Once the credential set is created and preferred credentials have been set up, whenever the HostSSHCredSet credential set is used for any of the Enterprise Manager operation, that operation will use SSH credentials as defined in the named credential SSHCRED1. The following graphic shows the HostSSHCredSet credential set listed as a default preferred credential for host targets.
HostSSHCredSet shown as a default preferred credential
You can now set the preferred credentials of regular regular Enterprise Manager administrators to use the SSHCRED1 named credential by editing/creating an administrator and granting Named Credential resource privileges. The following graphic shows the manage privilege grants UI for named credentials.
grant named credential resource privilege

Комментариев нет:

Отправить комментарий