Missed Team ’24? Catch up on announcements here.

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

will Repository Variables stored secured be destroy by echo?

Lars_langhans April 6, 2022

What I have done:

I have stored a .ssh/private-key (--- BEGIN...) into a repository variable with 'secured' marked. If it is a good idea I don't no.

Within a pipeline script I echoed such variable to a file like `echo ${VARIABLE} >~/.ssh/name`, chmod it to 600... btw: the file is 1675 bytes long, on bitbucket and local.

When I try to use `md5sum -b ~/.ssh/name` on such file the result is not the expected checksum, I have on my local system. I used different editors to create such variable, but the result is always the same.

But, the same procedure with the single line public key works as expected, the checksum is the same as on my local system and in pipeline script.

I'm working on Linux so line ending is always the byte 0x0a.

How can I see, the content is as expected?

 

2 answers

1 accepted

1 vote
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 12, 2022

Hi @Lars_langhans,

Pipelines does not currently support line breaks in environment variables. What we suggest is to base-64 encode the private key by running:

Linux

$ base64 -w 0 < my_ssh_key

Mac OS X

$ base64 < my_ssh_key

Then copy the base64-encoded private key from the terminal, and paste it as the value for a variable.

You can then create the private key file in your build with the following command

(umask 077 ; echo $MY_SSH_KEY | base64 --decode > ~/.ssh/id_rsa)

where MY_SSH_KEY replace with the name of your repository variable.

We have documentation about this here:

Kind regards,
Theodora

0 votes
Lars_langhans April 6, 2022

Thanks for the not documented feature, that carriage return 0x0a will replaced by 0x20  (space).

BTW: To see the full content of a file, I use 'od -x file', which works as expected.

Kind Regards

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events