Enabling password-less SSH for Ansible

Generate an SSH key pair on the Ansible administration node and distribute the public key to each node in the storage cluster so that Ansible can access the nodes without being prompted for a password.

Before you begin

Before you begin, make sure that you have the following prerequisites in place:

About this task

Important: If you are using Red Hat Enterprise Linux 9 only use these steps if you are a non-root user. If you are a root user, go to Bootstrapping a new storage cluster.

Procedure

  1. Generate the SSH key pair, accept the default file name and leave the passphrase empty.
    ssh-keygen
    For example,
    [ansible@admin ~]$ ssh-keygen
  2. Copy the public key to all nodes in the storage cluster.
    ssh-copy-id USER_NAME@HOST_NAME

    Replace USER_NAME with the new user name for the Ansible user. Replace HOST_NAME with the host name of the Ceph node.

    For example,
    [ansible@admin ~]$ ssh-copy-id ceph-admin@host01
  3. Create the user’s SSH config file.
    touch ~/.ssh/config
    For example,
    [ansible@admin ~]$ touch ~/.ssh/config
  4. Open the config file for editing.
    Set values for the Hostname and User options for each node in the storage cluster.
    Important: By configuring the ~/.ssh/config file you do not have to specify the -u USER_NAME option each time you execute the ansible-playbook command.
    Host host01
       Hostname HOST_NAME
       User USER_NAME
    Host host02
       Hostname HOST_NAME
       User USER_NAME
    ...

    Replace HOST_NAME with the host name of the Ceph node. Replace USER_NAME with the new user name for the Ansible user.

    For example,
    Host host01
       Hostname host01
       User ceph-admin
    Host host02
       Hostname host02
       User ceph-admin
    Host host03
       Hostname host03
       User ceph-admin
  5. Set the correct file permissions for the ~/.ssh/config file.
    chmod 600 ~/.ssh/config