Prevent gcloud from using Putty (google cloud sdk on windows)
Recent releases of Cloud SDK for Windows come with prepackaged putty executables (dir/bin/sdk folder) By looking at the source code of gcloud it seems that the use of PuTTY is hardcoded and it's currently not possible to choose another SSH client.
You can login to the GCP VM using MobaXterm, Windows Terminal or any other command-prompt application which supports ssh. All you need is the private key and the internal/external IP of your GCP instance(aka GCP VM).
Private key is usually C:\Users\<username>\.ssh\google_compute_engine
If you don't find that file you can know it's path by dry-running the gcloud login command.
$ gcloud compute ssh example-instance --zone=us-east1-b --dry-run
(--zone flag is optional.)
From the output, you'll notice the private key used in the command will end with a .ppk
extension (ppk
stands for a putty-private-key).
If you browse the File Explorer in the same path, you'll find another file without the .ppk
extension, that's the private key in the standard format.
Now you need the external/internal IP of your instance (You can use the internal IP if you're on VPN).
You can find out your VM's external IP using 2 ways.
-
log in to your VM normally and find out its external IP using the command
$ curl ifconfig.co
(I would suggest you not to use the external IP as it's a dynamic IP and will be changed at some point of time and moreover, you'll be able to use it only if the GCP instance is allowed to login via external IP by enabling the ssh port)
-
You can also find both internal/external IP in the GCP Console page (possible only if you've admin rights).
Once you've got the internal or external IP of your VM, you can run the below command to log in from your favourite shell.
$ ssh -i <path to private key without the (.ppk) extension> user@your_instance_IP