Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

echoing to a file ends up with the content of the file indented by 2 spaces #366

Closed
asok opened this issue Jan 26, 2016 · 4 comments
Closed

Comments

@asok
Copy link

asok commented Jan 26, 2016

Hi,
so here's the issue I want to echo a ssl certificate to a file as a part of my deployment:

ssl_certiciate = %(-----BEGIN RSA PRIVATE KEY-----
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-----END CERTIFICATE-----)

queue %(
  echo "-----> Setting SSL configuration..."
  echo "#{ssl_certificate}" > #{deploy_to}/shared/cert
) 

The file ends up having the newlines plus 2 spaces.
So instead of:

-----BEGIN RSA PRIVATE KEY-----
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I have:

-----BEGIN RSA PRIVATE KEY-----
  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I assume that is because of the indentation done here.

It seems ridicilous that echoing a string with the newline characters is not possible. What am I doing wrong?

@flowerett
Copy link
Contributor

Why do you need to echo it?
Probably it will be better to just copy regular file and put it wherever you want.

@asok
Copy link
Author

asok commented Jan 26, 2016

Why do you need to echo it?

We are building a deployment tool that is using mina under the hood. We store the certificates in the db, so it is convieniant for us to interpolate the ruby variable in the echo statement like that.

@kuon
Copy link

kuon commented Jan 27, 2016

I had the same issue, I ended writing the file locally and scp it to the server, it's also more robust than echo. (mina-scp works for that)

@d4be4st
Copy link
Member

d4be4st commented Jul 30, 2016

@asok you do not want to write your private key anywhere that can potentially end up on version controll as that is a security issue.

Please take @kuon's advice

@d4be4st d4be4st closed this as completed Jul 30, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants