- create a new user (only for this purpose)
- generate an SSH key pair for the user
ssh-keygen -t rsa -b 2048 -C username@github
# no password
# save as username@github- set the public key (
[email protected]) on the new account at settings/keys - copy the private key (
username@github) to thegithub/dir - copy / extend the
Dockerfileto your needs
do not commit the key add to
.gitignore
<username>@githubthe key will appear in the image layer! do not share with anyone untrusted
- script works on alpine or ubuntu (looks for
apkoraptpackage manager) - the script will setup the
.sshand.gitconfigfiles - it will add
github.comto known hosts - it will test the connection and exit 0 if successful or exit 1 if it fails (to stop the rest of the build)