Keychain ssh responses should end in a newline

Keychain ssh URLs like https://home.omg.lol/keychain/hug/ssh should end in a newline.

Why this matters:

I wanted to write a script what would grab the keychain URL and write ssh keys to authorized_keys. I want this to work ‘everywhere’, so I’m using sh and read. read returns a nonzero exit status when the last line does not have a terminating newline.

Reproduction:

$ ( WHO=hug; curl -o - --no-progress-meter https://home.omg.lol/keychain/${WHO}/ssh | read FOO; echo $? )
1

$ echo "hi" | read FOO; echo $?
0
$ ( WHO=hug; curl -o - --no-progress-meter https://home.omg.lol/keychain/${WHO}/ssh | hexdump -C | tail -n2)
00000050  20 68 75 67 40 6f 6d 67  2e 6c 6f 6c              | hug@omg.lol|
0000005c

$ ( echo "foo" | hexdump -C)
00000000  66 6f 6f 0a                                       |foo.|
00000004

Script, if you’re interested: addkey.sh
Unrelated, there’s no forum category for keychain.

1 Like

Yikes, I didn’t know about this — thanks for schooling me on the issue. It was a quick and easy fix, which is live now. Let me know if you notice any other issues related to it!