Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Accessing repo's ssh public key in pipeline script

Mike Pham August 5, 2021

Is there a way that I get the SSH public key that I set up for the repository? I've tried looking into the .ssh directory and I can't find id_rsa.pub. I also looked into .ssh/config and I can see that the identity file is in /opt/atlassian/pipelines/agent/ssh, but I can't find any public key in there either.

1 answer

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 18, 2021

Hi @Mike Pham and welcome to the community!

I don't think that the public SSH key is available, but you can create the file in the script of the step where you want to use it, and then access it.

If you add the following command in your script

ssh-keygen -y -f /opt/atlassian/pipelines/agent/ssh/id_rsa > /tmp/id_rsa.pub

it will create the public SSH key from the repo's private SSH key and store it in /tmp directory (because it is not possible to write in the directory /opt/atlassian/pipelines/agent/ssh/).

Another way would be to copy the public key from the repo's Settings and use that command instead in the script:

echo "paste_public_key_here" >> /tmp/id_rsa.pub

That command would need to get updated though if you decide to change the SSH keys in the repository.

Please feel free to let me know if that works for you and if you have any questions.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events