Skip to content

Instantly share code, notes, and snippets.

@ehpc
Last active July 8, 2025 13:28
Show Gist options
  • Save ehpc/660b49d02bdb1d856c34ea77c0da0999 to your computer and use it in GitHub Desktop.
Save ehpc/660b49d02bdb1d856c34ea77c0da0999 to your computer and use it in GitHub Desktop.
Quick setup of Ubuntu VM on MacOS for VsCode remote development
#!/bin/sh
set -e
VM_NAME=vm-ubuntu-dev
[ ! -f ~/.ssh/id_rsa.pub ] && ssh-keygen -b 4096 -t rsa
SSH_KEY=$(cat ~/.ssh/id_rsa.pub)
tee ~/$VM_NAME.yaml >/dev/null <<EOF
ssh_authorized_keys:
- $SSH_KEY
EOF
brew list multipass || brew install multipass
multipass info $VM_NAME || multipass launch --name $VM_NAME --cloud-init ~/$VM_NAME.yaml
VM_IP=$(multipass info $VM_NAME | awk '/^IPv4:/ { print $2 }')
echo "IP: $VM_IP"
code --remote ssh-remote+ubuntu@$VM_IP &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment