How GitHub Deploy Keys are handled with key comments
masterWhen using GitHub Deploy Keys, GitHub servers only accept the first matching key. Because deploy keys are scoped to specific repositories, a standard SSH connection might fail if the wrong key is presented first.
To solve this, the ssh-agent action uses key comments to map keys to specific repositories:
- Create key with comment: When generating your key, include the repository URL in the comment:
ssh-keygen ... -C "git@github.com:owner/repo.git". - Automatic Configuration: The action scans these comments and automatically configures Git (using
url.<base>.insteadof) and SSH (using a custom hostname/mapping) to ensure that requests to specific repositories use the correct corresponding key.