DevOps

How to Connect to Google Cloud VM Using SSH from macOS Terminal (Full Guide)

October 26, 2025
5 min read
78 views
How to Connect to Google Cloud VM Using SSH from macOS Terminal (Full Guide)

Connecting to your Google Cloud VM from macOS Terminal doesn’t need to be complicated. In this quick guide, you’ll learn how to set up SSH access step by step — from generating keys to enabling passwordless login.
 

Step 1: Generate SSH Keys

Open your macOS terminal and run:

ssh-keygen -t rsa -f ~/Desktop/gcp/gcp

This will create:

  • Private key → ~/Desktop/gcp/gcp

  • Public key → ~/Desktop/gcp/gcp.pub

Step 2: Add SSH Key to GCP Metadata

Go to:
Google Cloud Console → Compute Engine → Metadata → SSH Keys → Add Key

Paste the entire content of your gcp.pub file, which looks like:

ssh-rsa AAAAB3Nza... spotbreaks

⚠️ Note: The username at the end (e.g., spotbreaks) determines the SSH username you’ll use to connect.

🌐 Step 3: Connect to Your VM

Run:
 

ssh -i ~/Desktop/gcp/gcp spotbreaks@YOUR_VM_IP

Replace YOUR_VM_IP with your external VM IP.
If you see a welcome message — congrats, you’re in! 
 

Step 4: Enable Passwordless SSH Login

Add a shortcut in your SSH config file:
 

nano ~/.ssh/config

Then paste:
 

Host gcp-vm
    HostName 34.118.000.00
    User spotbreaks
    IdentityFile ~/Desktop/gcp/gcp

Save and exit (CTRL + X, then Y).
Now connect with:

 

ssh gcp-vm

Boom — passwordless, clean, and fast.

Pro Tips:

  • Keep your private key secure — never share it.

  • Use VS Code Remote SSH for development inside the VM.

  • You can reuse the same SSH key for multiple GCP instances.

Tags:

Google Cloud GCP SSH macOS DevOps Cloud Deployment Remote Server Tutorial

Enjoyed this article?

Subscribe to my newsletter to receive updates on new blog posts, tech insights, and development tips.

No spam. Unsubscribe at any time. Unsubscribe