Restart SSH service in cloud-config

Hi all,

I’m writing the /etc/ssh/sshd_config file via cloud-config. Specifically, I’m setting some trusted CA keys to allow SSH via signed certificates. I’ve had no issue getting the file modified, however I noticed that after RancherOS boots, the changes in /etc/ssh/sshd_config are not implemented until I login and manually do a:

system-docker restart console

So I tried adding that into a run command in my cloud-config:

runcmd:

  • system-docker restart console

However, when I boot with the cloud-config RancherOS loads all the way up until it’s about to launch the console and then freezes.

Is there another way I can restart the SSH daemon to ensure my changes are reflected when it boots up?

1 Like

trying to find the same solution, maybe you have to rebuild rancher os image doing the following:

#cloud-config
ssh_authorized_keys:
    - ssh-rsa YOUR_HASH rancher
hostname: gil
write_files:
    - path: /etc/ssh/sshd_config
      owner: root
      permissions: '0600'
      content: |
          PermitRootLogin yes
          PasswordAuthentication yes

This worked perfectly well.