Skip to content

Instantly share code, notes, and snippets.

@rcj4747
Last active October 4, 2018 20:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rcj4747/aaea3b1b5fbc285acf6d9ba366e65cd3 to your computer and use it in GitHub Desktop.
Save rcj4747/aaea3b1b5fbc285acf6d9ba366e65cd3 to your computer and use it in GitHub Desktop.
#!/bin/bash
cat <<EOF > meta-data
instance-id: iid-local01
local-hostname: cloudimg
EOF
cat <<EOF > user-data
#cloud-config
ssh_import_id: [ yourlaunchpadid ]
system_info:
default_user:
lock_passwd: false
plain_text_passwd: passw0rd
ssh_pwauth: true
users:
- default
EOF
genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data
rm user-data meta-data
echo "
Create a disk backed by the image:
qemu-img create -f qcow2 -b <orig-disk>.img boot-disk.img
Launch the instance with:
kvm -m 256 -net nic -net user,hostfwd=tcp::2222-:22 \
-drive file=boot-disk.img,if=virtio \
-drive file=seed.iso,if=virtio,media=cdrom -nographic"
@rcj4747
Copy link
Author

rcj4747 commented Oct 4, 2018

Once you're done you can ssh -o port=2222 ubuntu@localhost

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