Cannot login to vm using qemu nocloud cloud-init on macOS with Ubuntu cloud image

Viewed 621

I cannot login to an Ubuntu cloud image based VM started with qemu / nocloud.

I had it working before---really, I did---but I cannot get it to work now ... I'm stumped!

Please let me know what I'm doing wrong, or better, how I can debug these kinds of issues myself. Is there something in the boot output that will show the problem? I kinda suspect my seed.iso/cidata is not getting processed, but I don't know how to check that. I do get boot messages like:

[FAILED] Failed to start OpenBSD Secure Shell server.
See 'systemctl status ssh.service' for details.

which is probably why I cannot ssh in. I have tried logging in using the prompt provided directly after the boot messages using the user ubuntu, but I have not been able to login in that way either.

Here are my files / workflow:

Ubuntu cloud image:

$ md5sum ../../bases/focal-server-cloudimg-amd64-disk-kvm.img
f8f42f3bf4bb66512195e868bb5ee068  ../../bases/focal-server-cloudimg-amd64-disk-kvm.img

user-data

#cloud-config
users:
  - name: jra
    ssh-authorized-keys:
      - ssh-ed25519 AAAAC3NzaC1<snip> jra@host
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: sudo
    shell: /bin/bash
runcmd:
  - echo "AllowUsers jra" >> /etc/ssh/ssh_config
  - restart ssh

user-data (when trying direct ubuntu login)

#cloud-config
password: ubuntu
chpasswd: { expire: False }
ssh_pwauth: True

meta-data

instance-id: demo-1
local-hostname: demo

build.sh

rm -rf seed.iso
mkisofs -o seed.iso -V cidata -J -rock user-data meta-data

rm -rf vmimage.qcow2
qemu-img create \
         -f qcow2 \
         -o backing_file=$HOME/pks/vm-images/bases/focal-server-cloudimg-amd64-disk-kvm.img \
         vmimage.qcow2 \
         25G

start.sh

qemu-system-x86_64  \
  -machine accel=hvf,type=q35 \
  -cpu host \
  -m 2G \
  -nographic \
  -device virtio-net-pci,netdev=net0 \
  -netdev user,id=net0,hostfwd=tcp::2222-:22 \
  -drive if=virtio,format=qcow2,file=vmimage.qcow2 \
  -cdrom seed.iso

commands

$ sh build.sh
Total translation table size: 0
Total rockridge attributes bytes: 363
Total directory bytes: 0
Path table size(bytes): 10
Max brk space used 0
183 extents written (0 MB)
qemu-img: warning: Deprecated use of backing file without explicit backing format (detected format of qcow2)
Formatting 'vmimage.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=26843545600 backing_file=/Users/jra/pks/vm-images/bases/focal-server-cloudimg-amd64-

$ sh start.sh

<snip>

[  OK  ] Stopped OpenBSD Secure Shell server.
[FAILED] Failed to start OpenBSD Secure Shell server.
See 'systemctl status ssh.service' for details.
[  OK  ] Started snap.lxd.hook.inst…-497e-bb46-bc39b37792ba.scope.
[  OK  ] Listening on Socket unix for snap application lxd.daemon.
         Starting Service for snap application lxd.activate...
[  OK  ] Finished Service for snap application lxd.activate.
[  OK  ] Started snap.lxd.hook.conf…-4cbc-88ac-8bb3331c8a60.scope.

Ubuntu 20.04.2 LTS ubuntu ttyS0

ubuntu login: 

# It looks like vm starts well, except for failed Secure Shell server.
# (I have not read every line of boot output).
# I have tried logging in using the above prompt with different user-data
# configurations without success.

# switch to another terminal
$ ssh -v -i $HOME/.ssh/id_ed25519 -p 2222 jra@0.0.0.0
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/jra/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: /etc/ssh/ssh_config line 51: Applying options for *
debug1: Connecting to 0.0.0.0 [0.0.0.0] port 2222.
debug1: Connection established.
debug1: identity file /Users/jra/.ssh/id_ed25519 type 3
debug1: identity file /Users/jra/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.1

# times out

kex_exchange_identification: read: Connection reset by peer
0 Answers
Related