I’m currently trying to deploy my NodeJS API by dockerising it and put it onto an EC2, however I’ve head a dead end with this error: load pubkey "/root/.ssh/id_rsa": invalid format
Things I’ve tried
Converting my Private RSA Key from PSK1 to PSK8
Setting protected variable to false
(and various combinations of the above)
Using apt-get install openssl-client and converting the Private RSA Key from within the docker (but apparently I’m missing apt-get so I’ve also tried apk which also didn’t work so… ???)
Questionable:
The error mentions pubkey, but all tutorials have pointed to using my pem key which is generated from my EC2 setup. So perhaps I’m missing a pubkey? But I can’t find any material saying otherwise.
seems that decode in the Docker image is not available for base64, or it uses different flags.
Is there a specific reason to use this image for every job? I would leave this to the job which runs DinD and builds the image.
There’s two approaches I would recommend:
Change the --decode flag to the shorter -d and try again.
Modify the image for the deployment stage, e.g. to debian:latest. Do not use alpine, this is the base image layer for docker:19.03.12.
Explanation
Short local tests with Docker.
Docker 19.03.12
$ docker run -ti docker:19.03.12 sh
/ # base64 --help
BusyBox v1.31.1 () multi-call binary.
Usage: base64 [-d] [FILE]
Base64 encode or decode FILE to standard output
-d Decode data
Alpine
$ docker run -ti alpine:latest sh
/ # base64 --help
BusyBox v1.31.1 () multi-call binary.
Usage: base64 [-d] [FILE]
Base64 encode or decode FILE to standard output
-d Decode data
Debian
$ docker run -ti debian:latest sh
# base64 --help
Usage: base64 [OPTION]... [FILE]
Base64 encode or decode FILE, or standard input, to standard output.
With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options too.
-d, --decode decode data
-i, --ignore-garbage when decoding, ignore non-alphabet characters
-w, --wrap=COLS wrap encoded lines after COLS character (default 76).
Use 0 to disable line wrapping
--help display this help and exit
--version output version information and exit
The data are encoded as described for the base64 alphabet in RFC 4648.
When decoding, the input may contain newlines in addition to the bytes of
the formal base64 alphabet. Use --ignore-garbage to attempt to recover
from any other non-alphabet bytes in the encoded stream.
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report base64 translation bugs to <https://translationproject.org/team/>
Full documentation at: <https://www.gnu.org/software/coreutils/base64>
or available locally via: info '(coreutils) base64 invocation'
I thought that I send my answer already. The problem here is that the provided base64 binary isn’t the normal GNU base64. So in Debian it’s included by default. If you want to stick to your current image mostly all docker:* images are based on alpine linux. So you need only to install the coreutils package and everything should work as excepted.