Read host keys from environment variables

Philipp Marek philipp at marek.priv.at
Tue Aug 11 19:45:04 AEST 2026


Hi everybody,

for use in containers it would be nice to pull SSH host keys from 
environment variables.

So, as an example, with an environment variable similar to

    HOST_KEY_RSA="-----BEGIN OPENSSH PRIVATE KEY----- b3Blbn…AwQF 
-----END OPENSSH PRIVATE KEY-----"

(general whitespace, so "\r\n\t " being allowed) I'd hope for an 
sshd_config saying

    HostKeyFromEnv HOST_KEY_RSA

being enough.


I saw "HostKeyAgent", but providing a unix-socket to a different 
container
running an agent with the keys is more complex and more likely to fail 
than
using environment variables.

sshd could even be so nice as to drop these variables from child 
processes,
although for my sftp usecase it shouldn't matter.


Thanks for any feedback!


Ph.



More information about the openssh-unix-dev mailing list