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

How to pass a base64 encoded variable to the SFTP Deploy Pipeline

raschidjfr August 23, 2019

I'm trying to follow the guide to manage multiple repository ssh keys . I've added my ssh as a secure variable, encoded in base64. But how do I decode it to pass it into the pipe's variables (parameters)?

 

script:
  - pipe: atlassian/sftp-deploy:0.4.1
    variables:
      SSH_KEY: $MY_SSH_KEY_B64  //<- How do I decode it before passing it??
      ...

 

 

2 answers

1 accepted

1 vote
Answer accepted
raschidjfr August 29, 2019

Ok, just for the record, I managed to solve my problem. I don't know exactly what the problem was, but it all worked when I encoded the key using this online tool rather than using `base64 -w 0 < my_ssh_key`.

0 votes
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 25, 2019

Hi @raschidjfr ,

you should only provide encoded SSH_KEY as a variable and pipe will decode it to the ~/.ssh/pipelines_id automatically.


Cheers,
Alex

raschidjfr August 27, 2019

Thanks for your answer @Oleksandr Kyrdan . Sorry, I didn't fully get  you... should I pass it encoded or decoded? I tried saving it encoded as the tutorial states but then I'm getting "invalid format" error:

Load key "/root/.ssh/pipelines_id": invalid format
✖ Deployment failed.

 

Maybe there's something wrong with the key format but I've been using it without problem from my terminal. You know, my key file looks something like this:

-----BEGIN RSA PRIVATE KEY-----  // line break here
MIIEpAIBAAKCAQEA1fgwkzccOpKpb4Ln6wIaCVFWgnRX+vANU/s5E3K8boCYQ8FU // line break here
XVrfupIjyPudSgs1RJvMp13PPkLfq+O92bWHQaAkm0b4+xKts8BHsGt8S7FgQjTe // line break here

...

Z57q0odcy76rGBq2iiqH2YU9P4sDdqLj/r1ZRl+FURwhHk9ATaFx+w== // line break here
-----END RSA PRIVATE KEY----- // line break here
// There's a last line break here

 

So I encoded it with base64 -w 0 < my_ssh_key:

LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQ0KTUlJRXBB(...)klWQVRFIEtFWS0tLS0tDQo=

 

And then the I get the "invalid format" error when running the pipline. Any thoughts?

Like Abhishek Kumar likes this
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 28, 2019

Hi @raschidjfr ,

yep, encoded SSH_KEY as a variable according to the readme

# LINUX

$ base64 -w 0 < my_ssh_key

All your steps look good.

Try to check twice start and end of the encoded key before copying it, to prevent copying additional symbols.

Like raschidjfr likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events