Skip to content

Default password #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
IanMoroney opened this issue Nov 20, 2024 · 4 comments
Closed

Default password #228

IanMoroney opened this issue Nov 20, 2024 · 4 comments
Labels

Comments

@IanMoroney
Copy link

What happened:
I'm trying to log into a VM created from quay.io/containerdisks/ubuntu:24.04 using the default username ubuntu but I don't know what the default password is.
I tried using cloudInitNoCloud to set both a user with a password, and to set a password on its own, but neither have worked.
At the moment i'm not using bridge networking, so I don't have the ability to ssh into the guest, and virtctl ssh returns a "connection refused", so assigning the ssh_authorized_keys doesn't help me.
from virtctl vnc, i can see the guest is running and is at the login screen, i just can't get in.

What you expected to happen:
Trying to log into the machine

How to reproduce it (as minimally and precisely as possible):
Steps to reproduce the behavior.

Additional context:
Add any other context about the problem here.

Environment:

  • KubeVirt version (use virtctl version): 1.4.0
  • Kubernetes version (use kubectl version): 1.3.0
  • VM or VMI specifications: N/A
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  name: vm-template
  namespace: kvrunner
spec:
  runStrategy: Manual
  template:
    metadata:
      name: runner
    spec:
      architecture: amd64
      terminationGracePeriodSeconds: 30
      domain:
        devices:
          filesystems:
            - name: runner-info
              virtiofs: {}
          disks:
            - name: containerdisk
              disk:
                bus: virtio
            - name: cloudinitdisk
              disk:
                bus: virtio
          interfaces:
            - name: default
              masquerade: {}
        cpu:
          cores: 3
        resources:
          requests:
            memory: 14Gi
      networks:
        - name: default
          pod: {}
      volumes:
        - name: containerdisk
          containerDisk:
            image: quay.io/containerdisks/ubuntu:24.04
        # - name: runner-info
        #   configMap:
        #     name: runner-info-configmap
        - name: cloudinitdisk
          cloudInitNoCloud:
            userData: |-
              #cloud-config
              password: ubuntu
              users:
                - name: runner
                  password: runner
                  homedir: /home/runner
                  sudo: ["ALL=(ALL) NOPASSWD:ALL"]
              mounts:
                - [ runner-info, /runner-info/, virtiofs, "rw,relatime,user=ubuntu" ]
              packages:
                - jq
              bootcmd:
                - "sudo mkdir /opt/runner"
                - "curl -sL https://github.com/actions/runner/releases/download/v2.320.0/actions-runner-linux-x64-2.320.0.tar.gz | sudo tar -xz -C /opt/runner"
                - "sudo /opt/runner/bin/installdependencies.sh"
              runcmd:
                - "sudo chown -R runner: /opt/runner"
                - "sudo runuser -l runner -c '/opt/runner/run.sh --jitconfig $(jq -r '.jitconfig' /runner-info/runner-info.json)'"
                - "sudo poweroff"
@0xFelix
Copy link
Member

0xFelix commented Nov 20, 2024

You might have broken the cloud-init mechanism by making cloudinitdisk a disk. Can you try again with:

- name: cloudinitdisk
  cdrom:
    bus: sata

Edit: bus: virtio should be valid too.

@IanMoroney
Copy link
Author

That's interesting,
the official example has the cloudinitdisk also as a disk:
https://quay.io/repository/containerdisks/ubuntu

Trying it out as a cdrom now.

The request is invalid: spec.template.spec.domain.devices.disks[1].cdrom.bus: Bus type virtio is invalid for CD-ROM device

sata works for the bus.

Testing it now to see what happens.

@IanMoroney
Copy link
Author

No difference, sadly.

@IanMoroney
Copy link
Author

I believe i've found the answer.

And a more complete answer for anyone who finds this.

In order to log on with a password as a defined user, you need to set lock_passwd: false as part of your user definition.
Additionally, specifying a user in the users block will remove the default user (ubuntu).

No password is set by default, and you should use the passwd block as part of your user definition.
The value in that field should be a hashed value generated by mkpasswd --method=SHA-512 --rounds=4096 (as an example).
docs here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants