#OpenSSL cannot read SSH keys mounted as ...
1 messages · Page 1 of 1 (latest)
New line is missing in the end of the file when mounting file as secret directly
ssh-key-2 is loaded from CurrentModule() and ssh-key is passes as secret to module
dagger call test-fail --ssh-key file:id_ed25519 terminal
/ # cat ssh-key-2
-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----
/ # cat ssh-key
-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----/ #
to reproduce, just remove space from ssh key contents
func (m *SshKeyRepro) TestOkToo(ctx context.Context) *Container {
sshKeyContents, _ := dag.CurrentModule().Source().File("id_ed25519").Contents(ctx)
sshKey := dag.SetSecret("ssh-key", strings.TrimSpace(sshKeyContents))
return dag.
Wolfi().
Container(WolfiContainerOpts{
Packages: []string{"git", "openssh"},
}).
WithMountedSecret("/ssh-key", sshKey).
WithExec([]string{"ssh-keygen", "-y", "-f", "/ssh-key"})
}
🤔 who's adding the newline in the first case? Given that file doesn't seem to have it? https://github.com/sagikazarmark/daggerverse/pull/75/files#diff-be3e511fdda41f50bf714c70d2f2f4e781454e90cc71acafe6d2d6c85ed85d4e
UI is confusing a little bit. My local clone shows newline at the end of the file
I don't see it 🤔
130|marcos:daggerverse/ssh-key-repro (ssh-key-repro) (⎈ |N/A)$ cat id_ed25519
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACBdDxLqOrVgSd5LiowQMfzMcSp8zugMC/60aNmI8agO4gAAAKAwd8pgMHfK
YAAAAAtzc2gtZWQyNTUxOQAAACBdDxLqOrVgSd5LiowQMfzMcSp8zugMC/60aNmI8agO4g
AAAECNZ+zhBsEdCqirDfHbLTwM4w0Q1bTEZ15fSwzSRM/zOV0PEuo6tWBJ3kuKjBAx/Mxx
KnzO6AwL/rRo2YjxqA7iAAAAG21hcmtATWFyay1NMk1CUC5sb2NhbGRvbWFpbgEC
-----END OPENSSH PRIVATE KEY-----
oh, it is there indeed:
interesting.. because it's a line feed character without carriage return 🤔. Seems like go's Trimspace effectively deletes that character
yes, it is deletes all white space characters. not just look space and new ilne.
yes, that make sense. Maybe this might be changing the current implementation to https://go.dev/play/p/h5UXovuGHsl could be more accurate
here's the Z unicode category for the reference:
I'll add that to the issue