Signing back into the Community for the first time? You'll need to reset your password to access your account. Find out more.
Forum Discussion
Bastien
2 years agoNew Contributor
Bad characters when exporting SSH private key via CLI
I'm trying to export an SSH private key from 1password to my file system using
op read op://{vault id}/{item id}/private_key > id_25519
I'm using a Windows 11 machine, but working inside...
bpacia
2 years agoNew Contributor
I'm experiencing the same problem. I'm on macOS and
op read "op://{vault id}/{item id}/private_key?ssh-format=openssh" | cat -v
returns
-----BEGIN OPENSSH PRIVATE KEY-----^M
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACD1k9TWjiuIc6pmN3DBq71RGwEUIoOkDjsYJOm+7uKY6QAAAKgU9furFPX7
qwAAAAtzc2gtZWQyNTUxOQAAACD1k9TWjiuIc6pmN3DBq71RGwEUIoOkDjsYJOm+7uKY6Q
AAAEAOwWmP1G07Xg4XVF7hYJkR8IyeEYo83lJdZwctVRrGFPWT1NaOK4hzqmY3cMGrvVEb
ARQig6QOOxgk6b7u4pjpAAAAIUJhcnRlayBQYWNpYSA8YmFycGFjMDJAZ21haWwuY29tPg
ECAwQ=^M
-----END OPENSSH PRIVATE KEY-----^M
(this is a temporary key I only generated for purpose of this comment).
Trying to ssh-add
this key results in either "Error loading key "id_ed25519_git_hosting": invalid format" (on Raspberry Pi with OpenSSH_7.9p1 Raspbian-10+deb10u2+rpt1, OpenSSL 1.1.1n
) or error in libcrypto" (on
OpenSSH_9.3p1 Ubuntu-1ubuntu3, OpenSSL 3.0.10 1 Aug 2023`).
A workaround I found to remove those ^M
s is to use dos2unix
:
op read "op://{vault id}/{item id}/private_key?ssh-format=openssh" | dos2unix | cat -v
returns:
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACD1k9TWjiuIc6pmN3DBq71RGwEUIoOkDjsYJOm+7uKY6QAAAKgU9furFPX7
qwAAAAtzc2gtZWQyNTUxOQAAACD1k9TWjiuIc6pmN3DBq71RGwEUIoOkDjsYJOm+7uKY6Q
AAAEAOwWmP1G07Xg4XVF7hYJkR8IyeEYo83lJdZwctVRrGFPWT1NaOK4hzqmY3cMGrvVEb
ARQig6QOOxgk6b7u4pjpAAAAIUJhcnRlayBQYWNpYSA8YmFycGFjMDJAZ21haWwuY29tPg
ECAwQ=^M
-----END OPENSSH PRIVATE KEY-----