Distribute Your Public Key

The public key (id_rsa.pub or id_dsa.pub) needs to be installed on each target host to be scanned. Do this by appending the contents of the public key file to the ".ssh/authorized_keys2" file on each target host, in the home directory of the user for whom the key was created.

 

To distribute your public key:

1.    From the system where the key pair was generated, copy the public key to each target host. You can use the SSH secure copy (SCP) program for this by entering the following:

$ scp public_key username@targethost:.

Where public_key is either id_rsa.pub or id_dsa.pub.

For example, you might enter:

$ scp id_rsa.pub [email protected]:.

2.    Enter your user account password when prompted.

3.    Login to each target host as the user created for the purpose of authentication.

4.    Enter your user account password when prompted.

5.    Enter the following commands:

$ mkdir .ssh

$ chmod 700 .ssh

$ cat public_key >> .ssh/authorized_keys2

$ rm public_key

Where public_key is either id_rsa.pub or id_dsa.pub.  

If the "authorized_keys2" file already exists, the contents of the public key will be appended to it. If the "authorized_keys2" file does not already exist, it will be created and the public key will be appended. It's recommended that you check file permissions for "authorized_keys2" to ensure that the file is world-readable and owner-writable. See instructions below.

 

To verify permissions for the "authorized_keys2" file:

1.    Use the "chmod" utility to set permissions by entering the following command:

$ chmod 644 .ssh/authorized_keys2

2.    Verify permissions by entering the following command:

$ ls -l .ssh/authorized_keys2

3.    The file permissions should show up as:

-rw-r--r--