Simple way to start a FreeBSD guest VM on a remote Linux host

I am trying to boot a FreeBSD VM on a remote Linux host, CLI only, no VNC/GUI or anything and I also don't want to go through the installation process.

I tried to use a script like this: https://gist.github.com/cen1/ca6871542ba2d336a0db4fa053e2cb22

This worked perfectly fine for Archlinux but with FreeBSD I can't ssh into the box and virt-viewer/virsh just hangs with
Escape character is ^] (Ctrl + ])

Do qcow2 images not come with SSH preinstalled? Can I achieve what I want without needing to generate my own custom image, would really like to avoid that.
 
Moving this to "Emulation and virtualization", seems more appropriate.

The cloud-init images might be more useful for you.
 
Cloud-init image does indeed react to SSH but I can't figure out the default user. root/root or freebsd/freebsd doesn't work. No password doesn't work either.
 
Ok, for anyone wondering you need to do the following:

create user-data file:
Code:
#cloud-config
users:
  - name: freebsd
    ssh-authorized-keys:
      - ssh-ed25519 your-key-here me@localhost
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    shell: /bin/tcsh
    groups: wheel
chpasswd:
  list: |
     freebsd:freebsd
  expire: False
ssh_pwauth: True

create meta-data file:
Code:
instance-id: freebsd-worker-1
local-hostname: freebsd

Generate an iso for cloud-init to run:
Code:
genisoimage -output freebsd_seed.iso -volid cidata -joliet -rock user-data meta-data

Finally, run the script from gist in original post. This will let you in with user freebsd/freebsd (not sure about key, doesn't seem to work).
 
If I read this correctly, OP wants to run the BSD as a guest under a Linux host. This is fairly trivial to do. The thing OP needs to do is to become familiar with the qemu command line options. Stay away from libvirt, as it is an ill conceived overlay interface

qemu will start the BSD VM and create a window that is the text-terminal representation. Where is becomes less trivial is when you start adding guest NIC interfaces and routing them to/through the host.

This should get you started
sudo qemu-system-x86_64 \
-machine q35 \
-cpu max \
-accel kvm \
-m 4G \
-drive file=./image.img,index=0,media=disk,format=raw \
-spice port=3001,disable-ticketing=on

This will create a spice protocol listener on host port 3001. if spice isn't to your liking then there are other virtual console options that are documented in the qemu manpage
 
Cloud-init image does indeed react to SSH but I can't figure out the default user. root/root or freebsd/freebsd doesn't work. No password doesn't work either.

See nuageinit(7):

The default user for nuageinit is a user named freebsd with a password
set to freebsd and a login shell set to /bin/sh.

However, it's only created when no user is specified or "default" is specified as the entry in the "users" parameter. The example from the man page (excerpt):

Code:
...
     users:
       - default
       - name: user
         gecos: Foo B. Bar
         sudo: ALL=(ALL) NOPASSWD:ALL
         ssh_authorized_keys:
           - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAr...
...

Check my datastore I used recently:

Code:
  meta-data:
    instance-id: 'ca42fcaa-ac78-4b60-b75c-f0f28df5cec3'
    local-hostname: freebsd.lan
  network-config:
    ethernets:
      vtnet0:
        addresses:
          - 192.168.8.2/24
        gateway4: 192.168.8.1
        nameservers:
          search: []
          addresses: [172.0.0.1]
  user-data:
    users:
      - name: user
        homedir: '/user'
        ssh_authorized_keys:
          - bla bla bla
        sudo: 'ALL=(ALL) NOPASSWD:ALL'
    packages:
      - sudo
    package_update: True
    package_upgrade: True
 
Back
Top