I have an autoscaling Jenkins cluster on AWS, which spawns & runs agents via JNLP. Both Master & Slaves run on Ubuntu. I don't quite understand where Jenkins actually stores the SSH keys for Gitlab, or if/how the slaves are expected to use it. Whenever I run a Jenkins job on my slaves, I get the following:
git clone git@git.mydomain.co.uk/myproject.git
Cloning into 'build-scripts'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I can confirm the behaviour by SSHing onto the slaves and running the same command manually. The slave .jar is run as a "Jenkins" user, but I'm unable to use a Git clone when being the default "ec2-user", "Jenkins" user, or even as root. I have the Git plugin, Git Credentials plugin, & Git Server plugins installed, which I had previously believed would copy the keys over to the slave on startup. I'm able to run the exact same SSH command from the Master and it works fine, as well as the Master being able to talk to Git to clone repositories as multibranch pipelines.
It might be a simple solution, but I'm a bit stumped. Does anybody know what is required to allow the slaves to SSH/copy the key to somewhere usable?