Last active
July 8, 2025 13:28
-
-
Save ehpc/660b49d02bdb1d856c34ea77c0da0999 to your computer and use it in GitHub Desktop.
Quick setup of Ubuntu VM on MacOS for VsCode remote development
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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