SSH Access to Google Cloud VM Instances
Google Cloud VM instances can be accessed via the browser-based SSH console in the GCP Console, or via a standard SSH client after configuring the instance.
Method 1 – Browser-based SSH (quickest)
- In the GCP Console, go to Compute Engine → VM Instances.
- Click the SSH button next to your instance.
Method 2 – Enable root and password SSH (for SSH clients)
- Connect via the browser SSH console first.
- Set a root password:
sudo passwd root - Edit the SSH config:
sudo nano /etc/ssh/sshd_config - Set:
PermitRootLogin yes PasswordAuthentication yes - Restart SSH:
sudo systemctl restart sshd - Open port 22 in the GCP firewall rule for your VM's network.
Security note: Enabling root SSH with password auth is not recommended for production. Prefer key-based auth or use IAP tunnelling (see below).
Method 3 – gcloud SSH (recommended for admin access)
# SSH via gcloud (handles key management automatically)
gcloud compute ssh INSTANCE_NAME --zone=ZONE
# With IAP tunnel (no public IP required)
gcloud compute ssh INSTANCE_NAME --zone=ZONE --tunnel-through-iap