Skip to content

Instantly share code, notes, and snippets.

@clindner3
Last active March 15, 2022 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clindner3/902054b15a367f565f188c385dcb0056 to your computer and use it in GitHub Desktop.
Save clindner3/902054b15a367f565f188c385dcb0056 to your computer and use it in GitHub Desktop.
cloud-init creates 0 byte .ssh/authorized_keys file in defined users directory despite ssh key present in user-data for that user
-- analyzed user-data
➜ tools git:(main) python3 validate-yaml.py ~/play/http/user-data
/Users/clindner/play/http/user-data - ok
➜ tools git:(main)
2022-03-10 02:03:44,141 - handlers.py[DEBUG]: start: modules-final/config-scripts-user: running config-scripts-user with frequency once-per-instance
2022-03-10 02:03:44,141 - util.py[DEBUG]: Writing to /var/lib/cloud/instances/iid-datasource-none/sem/config_scripts_user - wb: [644] 25 bytes
2022-03-10 02:03:44,142 - helpers.py[DEBUG]: Running config-scripts-user using lock (<FileLock using file '/var/lib/cloud/instances/iid-datasource-none/sem/config_scripts_user'>)
2022-03-10 02:03:44,142 - handlers.py[DEBUG]: finish: modules-final/config-scripts-user: SUCCESS: config-scripts-user ran successfully
2022-03-10 02:03:44,142 - stages.py[DEBUG]: Running module ssh-authkey-fingerprints (<module 'cloudinit.config.cc_ssh_authkey_fingerprints' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_ssh_authkey_fingerprints.py'>) with frequency once-per-instance
2022-03-10 02:03:44,142 - handlers.py[DEBUG]: start: modules-final/config-ssh-authkey-fingerprints: running config-ssh-authkey-fingerprints with frequency once-per-instance
2022-03-10 02:03:44,142 - util.py[DEBUG]: Writing to /var/lib/cloud/instances/iid-datasource-none/sem/config_ssh_authkey_fingerprints - wb: [644] 24 bytes
2022-03-10 02:03:44,143 - helpers.py[DEBUG]: Running config-ssh-authkey-fingerprints using lock (<FileLock using file '/var/lib/cloud/instances/iid-datasource-none/sem/config_ssh_authkey_fingerprints'>)
2022-03-10 02:03:44,143 - util.py[DEBUG]: Reading from /etc/ssh/sshd_config (quiet=False)
2022-03-10 02:03:44,143 - util.py[DEBUG]: Read 3316 bytes from /etc/ssh/sshd_config
2022-03-10 02:03:44,144 - util.py[DEBUG]: Changing the ownership of /home/general/.ssh to 1000:1000
2022-03-10 02:03:44,144 - util.py[DEBUG]: Writing to /home/general/.ssh/authorized_keys - wb: [600] 0 bytes
2022-03-10 02:03:44,144 - util.py[DEBUG]: Changing the ownership of /home/general/.ssh/authorized_keys to 1000:1000
2022-03-10 02:03:44,144 - util.py[DEBUG]: Reading from /home/general/.ssh/authorized_keys (quiet=False)
2022-03-10 02:03:44,145 - util.py[DEBUG]: Read 0 bytes from /home/general/.ssh/authorized_keys
2022-03-10 02:03:44,145 - handlers.py[DEBUG]: finish: modules-final/config-ssh-authkey-fingerprints: SUCCESS: config-ssh-authkey-fingerprints ran successfully
2022-03-10 02:03:44,145 - stages.py[DEBUG]: Running module keys-to-console (<module 'cloudinit.config.cc_keys_to_console' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_keys_to_console.py'>) with frequency once-per-instance
general@ubuntu-template:/var/log$ more /etc/issue
Ubuntu 20.04.4 LTS \n \l
general@ubuntu-template:/var/log$ uname -a
Linux ubuntu-template 5.4.0-104-generic #118-Ubuntu SMP Wed Mar 2 19:02:41 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
general@ubuntu-template:/var/log$
# Host/process that is servering user-data
➜ ~ packer -v
1.7.10
#cloud-config
autoinstall:
version: 1
locale: en_US
keyboard:
layout: us
ssh:
install-server: true
allow-pw: true
identity:
hostname: ubuntu-template
password: xyqhxddsG.MVTqI
username: general
realname: general
users:
- name: general
sudo: True
ssh-authorized-keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDFVjD+7ad3ZtilRlcKGDCvfXbaLxuG0/OKdpzA4a6mOFtKRm7dZsXi29FvSLbxGVz76Ji+B+sr9kkMPqUkImdgxoP9wtvdqf3vkPXE7NCpeRNIFjN+42c6GiwqS8Owo+btT7+/S9wF2JDw8CgmFgqA0tKz5sUmCa/ymBGL27WwibNBTckb2Dww34Hwar5U1iYdUJud0bBTxkAP4iaSJk8t7sMVMTUt5V9xqy2gT43STYdpUJAkex8HPUuZpENYSXnejfqvbGgjTcx+nAIv+FWc+jyThv4aoWyDND1OQoczGmQLPmyTymg44mcoVNSVK64QvkrbXXcC4RzMZt3Tb3xyTh7/8gQnfhmnycDUBZ0tuzsLYjIHGxV+nSbx7aNGyUiW866kom7F3rFx4oMOTWfeSLFTt13vVOMBzDOtQwzSyJbKmbUIvFc9P6TdnKTWJcOtK1ucErD4A/1g5cJrXsh5OvP8s8h4gzx8T5lEPNuLe/c3JkZHcQxiG3K64poVohaLkVspIIpTTAaRJM0x8Jt8bbMHy23pBpaY1PR459vr4Xp7Z9BP7eI/6zRHFfypo9naaCXridGeKEBucA+6wly/ObdHPyKxtxzKueNZWsS9MO2UfXUowMaH2ZXqAy+zyOK6NgCNOv7sMXDQI5rKYP/gOmuVAOvVT4WZZP7cLOAW8w== cler@Cmb-2091.ler-home.network
refresh-installer:
update: false
ssh:
install-server: yes
allow-pw: yes
packages:
- qemu-guest-agent
@tonycasanova
Copy link

Seems like an interesting ssh-rsa value. cler@Cmb-2091.ler-home.network. Does that one work and it makes the extra zero byte file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment