"ssh-keygen -y" vs. "ssh-keygen -e", and input from STDIN
Philipp Marek
philipp at marek.priv.at
Tue Nov 17 23:42:44 AEDT 2026
I (again) stumbled over the "-e" vs. "-y" option for converting
a private (host) key into a OpenSSH public key.
The man page says
-e This option will read a private or public OpenSSH key file
and print to stdout a public key in one of the formats
specified by the -m option.
but there's no option to receive the OpenSSH public key format.
(ssh-keygen.c has a strcasecmp(optarg, "ssh2") call for the 'm' option,
but that returns RFC4716.)
After wasting some time the internet reminds me that there's a '-y'
option as well, which returns the format I need.
But "-f" doesn't understand "-" for stdin, and /proc/self/fd/0
is rejected because the access mode is too open.
I'd like to ask for
- "-f" allows "-" for stdin;
- "ssh-keygen" doesn't check access modes on non-files;
- "-m" also provides "openssh" format.
Unrelated, this "export public key" does a few getrandom() calls,
eating 8 plus 48 plus 32 bytes of (potential) entropy;
perhaps the random seeding could be moved a bit to only be run
when there's an actual need for randomness.
Thanks!
More information about the openssh-unix-dev
mailing list