Michael pointed me into the right direction - thank you!
Wasn't aware of the possibility to feed the system with a new cloud config and thought I had to change some configs on different places anywhere in the system...
Another problem seemed to be that CoreOS uses cloud-init a little bit different then shown in the cloud-init documentation and so you can find some different solutions that wont work for CoreOS.
Problem 1: A reboot resets the ssh port to 22
I've found this page in the documentation and I found out that I edited the sshd_config correctly, but the system used the sshd.socket after the reboot, so I had to (re)start sshd all the time...
Solution: Disabling the sshd.socket activation
sudo systemctl mask --now sshd.socket
sudo systemctl enable sshd.service # VERY IMPORTANT!
sudo systemctl restart sshd.service
Very important: You can lock yourself out of the system! You may want to check if you have access to the login shell via your providers control panel (rescued me).
The documentation says you have to execute command 1 and 3 above, but the sshd service is disabled after a reboot, so you have to enable it before the reboot!
As an alternative you may want to stick with the sshd.socket and change the port there. It is also documented in the link above.
Problem 2: The reset of my password after each reboot
Solution: Create a new cloud-init.yaml
I could create a better cloud-init.yaml and reapply it. Just changed the password and added my ssh-keys for the existing user and called
sudo coreos-cloudinit --validate --from-file=/path/to/cloud-init.yaml
to check the file. Removing the --validate
flag will apply the cloud-init.yaml and change the password (good to test it), but a reboot will still reset it!
As I found out, the coreos-cloudinit
command is not meant to be run by any users manually. To update the configuration for the reprovisioning at the reboot, we have to overwrite another file:
sudo cp /path/to/cloud-init.yaml /var/lib/coreos-install/user_data
Afterwards my password was the correct one after a reboot.