Unclear on how to encrypt an SSH private key

I’m attempting to use an SSH private key as an encrypted secret for deployment; I can’t seem to get the syntax right.

Here’s what I’ve tried:

$ drone encrypt <user>/<repo> '-----BEGIN OPENSSH PRIVATE KEY-----\n...\n-----END OPENSSH PRIVATE KEY-----'

(note that newlines are important in a private key, so my string includes literal newlines)

This produces the following error:

Incorrect Usage: bad flag syntax: -----BEGIN OPENSSH PRIVATE KEY-----\n...\n-----END OPENSSH PRIVATE KEY-----

What syntax should I be using?

Recently saw this, which appears similar: Incorrect Usage: bad flag syntax when adding secret ssh key as a string

you can read the secret from file using the @ syntax

drone encrypt secret octocat/hello-world @path/to/file
2 Likes

Thank you, this helps me a lot. Also, I think this syntax explanation should put in drone documentation.