- 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 (
username@github.pub
) on the new account at settings/keys - copy the private key (
username@github
) to thegithub/
dir - copy / extend the
Dockerfile
to your needs
do not commit the key add to
.gitignore
<username>@github
the key will appear in the image layer! do not share with anyone untrusted
- script works on alpine or ubuntu (looks for
apk
orapt
package manager) - the script will setup the
.ssh
and.gitconfig
files - it will add
github.com
to 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)