#OpenSSL cannot read SSH keys mounted as ...

1 messages · Page 1 of 1 (latest)

manic lion
#

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"})
}
manic lion
#

UI is confusing a little bit. My local clone shows newline at the end of the file

rancid scroll
# manic lion UI is confusing a little bit. My local clone shows newline at the end of the fil...

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

manic lion
light vessel
#

that key is the direct output of ssh-keygen

#

I haven't touched the file on purpose

rancid scroll
#

here's the Z unicode category for the reference:

#

I'll add that to the issue