1Password / load-secrets-action

Load secrets from 1Password into your GitHub Actions jobs
https://developer.1password.com
MIT License
197 stars 27 forks source link

SSH private key read with ?ssh-format=openssh causes ^M (DOS/Windows line-ending) #59

Closed Japje closed 1 week ago

Japje commented 11 months ago

When using op to get an SSH private key and use it for CI/CD purposes i ran into this issue.

op read "op://some-vault/some-entry/private key?ssh-format=openssh" > /tmp/key.txt

there are windows line endings

$ grep -r $'\r' /tmp/key.txt 
-----BEGIN OPENSSH PRIVATE KEY-----
lz+m8YgbS6fn/D+URRBMAAAAAAECAwQF
-----END OPENSSH PRIVATE KEY-----

image

When trying to load the key this will result in an error Load key "/tmp/key.txt": error in libcrypto

removing the line endings with dos2unix or tr -d '\r' fixes this.

bartekpacia commented 8 months ago

Cross-linking this discussion https://1password.community/discussion/142733/bad-characters-when-exporting-ssh-private-key-via-cli

It's probably already fixed since https://app-updates.agilebits.com/product_history/CLI2#v2250101

SimonBarendse commented 1 week ago

Thanks @bartekpacia ! That indeed seems like that was the root cause of this.

I'm going to close this ticket as solved, but please let us know if you're still running into this after that CLI fix and we can re-open to investigate further.