An SSH key is a cryptographic key pair: a private key and its corresponding public key. Together with a remote host, username, network connection, and SSH client, the pair supports secure-shell authentication without relying on a password. section 3.1.2 section 4.1.2
Use the two files for different purposes:
- Keep the private key secret; store it as a GitHub Actions secret when automation needs it. section 4.1.2
- Install the public key on the remote machine or provision it on new instances. section 4.1.2
- Create a purpose-built pair for automation instead of exposing a personal key such as ~/.ssh/id_rsa. section 4.1.2
- Ensure the required keys exist on both the machine running Ansible and the machines it configures. section 4.2
Create a dedicated automation key pair
Run ssh-keygen -t rsa -b 4096 -f github_actions_key -N "". This creates github_actions_key as the private key and github_actions_key.pub as the public key. Add the private file to a repository secret named SSH_PRIVATE_KEY, and install the public file on the remote instance. section 4.1.2
