It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

0 votes
Answer accepted

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`.

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

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?

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
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,032 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you