Using SSH-Key Authentication

AI Tools

To use key authentication, you must provide the SSH key file used in all the cluster servers to the hosts file, which is usually located from the light-app directory in this path: ansible/inventories/cluster_example/hosts.

To use SSH-key authentication instead of a plain text password, see the article on How To Configure SSH Key-Based Authentication on a Linux Server.

After you have configured the SSH key for authentication, you can connect from the installation server to the target with the ansible_ssh_private_key_file instead ofansible_ssh_pass, in the following format:

ansible_ssh_private_key_file=<private RSA key file path>

With the default configuration, the top section of the hosts file lines are configured as below:

server00 ansible_host=rack11-server92 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_pass=light ansible_become_user=root ansible_become_pass=light

As an example, assume that the SSH key for the servers is located at /root/mykey.txt. If so, change the configuration line to this:

server00 ansible_host=rack11-server92 ansible_connection=ssh ansible_ssh_user=root ansible_ssh_private_key_file=/root/mykey.txt ansible_become_user=root ansible_become_pass=light