On your VS Code install an extension Remote – SSH from Microsoft
Set up your SSH Key:
using your terminal navigate to ~/.ssh

Place your public key on the vm in ~/.ssh/authorized_keys
Make sure permissions are correct:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Add the VM to your SSH config
Edit ~/.ssh/config on your laptop:
Host myvm HostName YOUR_VM_IP_OR_DNS User YOUR_USERNAME IdentityFile ~/.ssh/<your private key pair>
ie.
HostName <your public ip>
Host gcp-vm
User thecloudadoption_blog
IdentityFile ~/.ssh/gcp_vscode
IdentitiesOnly yes
For GCP VMs, SSH Key format:
ssh-keygen -t ed25519 -f ~/.ssh/gcp_vscode -C "thecloudadoption_blog"
Then display the public key, copy on the VM in GCP console
cat ~/.ssh/gcp_vscode.pub
It will look something like:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB... thecloudadoption_blog
Google Cloud accepts that format directly.
Then you can add the private key on your local config file as explained above.
Connect from VS Code
Open VS Code
Press Ctrl+Shift+P
Run: Remote-SSH: Connect to Host…
Pick myvm or your VM name
VS Code opens a window connected to the VM, and you can edit files there directly
Run python Code within VS Code:
Install the python plugin for the VM-> Extensions-> python.
Select the Python interpreter
Press:
⌘⇧P
Type:
Python: Select Interpreter
Choose something like:
/usr/bin/python3
or your virtual environment:
/home/thecloudadoption_blog/venv/bin/python
If no interpreters appear, we’ll need to install Python or point VS Code at it.










