Andreas
Andreas

Reputation: 307

Why does dockerised SSH service not start since it can not load host-keys?

I am trying to dockerize an SSH service/daemon not unlikely as described here: https://docs.docker.com/engine/examples/running_ssh_service/#build-an-eg_sshd-image

In the container, when I try to /usr/sbin/sshd I get

Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Could not load host key: /etc/ssh/ssh_host_ed25519_key

I tried to ssh-keygen -A and manually:

user@3df98eeeb0d7:/home/dev/$ sudo ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''

But, after failing to load host keys again after /usr/sbin/sshd, I am still not successful:

user@3df98eeeb0d7:/home/dev/$ /etc/init.d/ssh status
 * sshd is not running

Since the creation of new keys is not working, I do not have a clue how to solve my problem.

Upvotes: 1

Views: 1220

Answers (1)

Andreas
Andreas

Reputation: 307

Sometimes you need super user rights

sudo /usr/sbin/sshd

Solves your problem. Although on most containers your user runs all commands in root context.

Upvotes: 1

Related Questions