Featured image of post ansible | Cache SSH key to avoid password input each time

ansible | Cache SSH key to avoid password input each time

Background

When using Ansible, to avoid the need to enter the SSH password each time a task is executed, we can cache the SSH key.

Caching SSH Keys with Ansible

  1. Start the ssh-agent background program

eval “$(ssh-agent -s)”

  1. Add the key to ssh-add, only input the password once

ssh-add ~/.ssh/xxx

  1. Verify if the key is successfully cached

ssh-add -l

Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy 🚀
Published: 58 Posts  |  Total Views: ... views
Uptime: ...  |  Site Visits: ... views