How can you SSH to a GKE node (Private/Public)?

1/8/2020

SSH to GKE node private IP from the jump server (Bastion host) is not working.

I even tried the following as suggested by one of my friends, but it did not help.

gcloud compute instances add-metadata $INSTANCE_NAME_OR_INSTANCE_ID --metadata block-project-ssh-keys=false --zone $YOUR_VM_ZONE --project $YOUR_PROJECT

Also please confirm if the solution works for Private GKE too.

-- k_vishwanath
google-cloud-platform
google-kubernetes-engine
kubernetes
ssh

2 Answers

1/8/2020

GKE node is just a GCE VM. You can just access it as a normal GCE instance if with proper privilege and ssh key configured.

One thing worth to mention that GCP support IAP based ssh port forwarding

-- Sam Liao
Source: StackOverflow

1/8/2020

I have added my ssh keys using gcloud CLI, as in the console the edit option is disabled for all gke nodes.

Now I'm able to do SSH.

-- k_vishwanath
Source: StackOverflow