Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to use Compute Engine - GCE with putty

Pre-requisite: go to http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html download http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe and http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe

Run puttygen and generate the key

  1. Click 'Generate' move the mouse around as instructed and wait

  2. enter your desired username

  3. enter your password

  4. save the private key

  5. copy the entire content of the 'Public key for pasting into OpenSSH authorized_keys file' window. Make sure, you copy every single character from the beginning to the very end!

  6. go to the cloud console http://cloud.google.com/console select your project and under Compute Engine / VM instances click on 'New instance' click on the advanced options link paste in the contents copied at step 5 into the entry box indicated

7. note the IP address of the instance once it is complete

8. Open putty, from the left hand menu go to Connection / SSH / Auth and define the key file location which was saved at step 4

9. from the left hand menu go to Connection / Data and define the same username as the one at step 2

10. Enter the IP address noted at step 7 11. name the connection below saved Sessions as 'GCE' click on 'Save'

12. double click the 'GCE' entry you just created 13. accept the identy of the host

14. login with the password given at step 3

15. sudo su - and you are all set

@mdjacobsen

This comment has been minimized.

Copy link

@mdjacobsen mdjacobsen commented Sep 2, 2014

Man, you are a champion. Totally saved my bacon. The GCE quickstart was utterly worthless. But you sir - you are a hero. You have my eternal gratitude.

@andresesfm

This comment has been minimized.

Copy link

@andresesfm andresesfm commented Oct 2, 2014

Great guide

@tonyaom

This comment has been minimized.

Copy link

@tonyaom tonyaom commented Apr 5, 2015

Pefect, simple, easy to follow. Work instantly
Google document is useless. Yours is the best. Thank you

@herveviet

This comment has been minimized.

Copy link

@herveviet herveviet commented Jun 4, 2015

Thank youuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu feczo,it is the best tuto.

@samdasoxide

This comment has been minimized.

Copy link

@samdasoxide samdasoxide commented Jul 10, 2015

Followed every bit of your instruction when I double click on GCE it opens the terminal and shows "server refused our key"

@slahiruk

This comment has been minimized.

Copy link

@slahiruk slahiruk commented Jul 14, 2015

This works for everything!!! I tried this guide on Mobaxterm as well and voila!! (because it has an sftp browser)

@mickeywilko

This comment has been minimized.

Copy link

@mickeywilko mickeywilko commented Jul 27, 2015

Many thanks for taking the time to write this.

@bozhan

This comment has been minimized.

Copy link

@bozhan bozhan commented Aug 10, 2015

I was trying this in various ways but never figured out how to define my username :(
Thank you very much for the detailed guide feczo!

@iamkingsleyf

This comment has been minimized.

Copy link

@iamkingsleyf iamkingsleyf commented Oct 9, 2015

thanks, this worked

@danilowagner

This comment has been minimized.

Copy link

@danilowagner danilowagner commented Oct 24, 2015

Thanks feczo! This works .

@googleirfan

This comment has been minimized.

Copy link

@googleirfan googleirfan commented May 5, 2016

Thanks very much for sharing this article. I have followed it accordingly but ended with an error:
"Unable to use key file "C:\Users\myname\Desktop\sshkey.ppk" (OpenSSH SSH-2 private key)"
I did added ssh public key in server Authorization-keys file and it worked well.

@jbhangoo

This comment has been minimized.

Copy link

@jbhangoo jbhangoo commented May 16, 2016

Better than Google's own documentation -- thank you!

@costnomics

This comment has been minimized.

Copy link

@costnomics costnomics commented Feb 15, 2017

Google documentation is not good . This is awesome, able to login in the first attempt...

@dtennes

This comment has been minimized.

Copy link

@dtennes dtennes commented Mar 1, 2017

Outstanding step by step. A little confusion around step 6 (regarding references to the Instance object menu tabs), but once I made the connection, it was smooth sailing. Greatest compliments.

@dtennes

This comment has been minimized.

Copy link

@dtennes dtennes commented Mar 1, 2017

So this is what you need to do if you have an existing instance for a Compute Engine instance. This is simply an alternative to the navigation instructions for "step 6" above (based on my configuration). Your situation my be different...
clarification1

clarification2

@rupesh-patel-1

This comment has been minimized.

Copy link

@rupesh-patel-1 rupesh-patel-1 commented Mar 29, 2017

@feczo Amazing !! you saved my day, @dtennes thanks for the post on exiting instances, actually came back to post the same :)
I wonder why the project wide ssh keys doesn't work for me, exactly had followed the Google Documentation but no luck.

@jsadove

This comment has been minimized.

Copy link

@jsadove jsadove commented May 24, 2017

It's pathetic that Google cannot write clear documentation. It's a real competitive disadvantage to AWS.

@idx57

This comment has been minimized.

Copy link

@idx57 idx57 commented Sep 7, 2017

@samdasoxide Followed every bit of your instruction when I double click on GCE it opens the terminal and shows "server refused our key"

I have the same situation, but don't know why.

@idx57

This comment has been minimized.

Copy link

@idx57 idx57 commented Sep 7, 2017

I tried again, it works. @samdasoxide

@logiclessindian

This comment has been minimized.

Copy link

@logiclessindian logiclessindian commented Dec 29, 2017

wow, amazing. I literally followed the procedure and it worked !! Thanks much.

@arifrohim

This comment has been minimized.

Copy link

@arifrohim arifrohim commented Jan 30, 2018

Hi there !
I suggest you can use simple way to login as root via putty with this root access trick
https://github.com/arifrohim/rootaccess/blob/master/README.md

@lohcheewai

This comment has been minimized.

Copy link

@lohcheewai lohcheewai commented Feb 1, 2018

Sir! Where are you from? From Mars, isnt it?
Thank you so much much!!!!

@anamihaela88

This comment has been minimized.

Copy link

@anamihaela88 anamihaela88 commented Feb 6, 2018

Great!

@sradforth

This comment has been minimized.

Copy link

@sradforth sradforth commented Mar 7, 2018

Excellent and useful writeup,

@bit-scientist

This comment has been minimized.

Copy link

@bit-scientist bit-scientist commented Mar 24, 2018

sorry if it is a dumb question, which IP address to insert at stage 10, internal IP or External IP?

@hashratez

This comment has been minimized.

Copy link

@hashratez hashratez commented Mar 24, 2018

OMG, I spent HOURS trying to figure out Google's instructions... I did it in 5 minutes following yours. THANK YOU.

@taka-hkd

This comment has been minimized.

Copy link

@taka-hkd taka-hkd commented Mar 30, 2018

I found this article helpful and wrote Japanese translation for Japanese-speaking readers as fork. Thank you.
https://gist.github.com/taka-hkd/ff62715143d03ca7d64f5bb58837c715

@bit-scientist

This comment has been minimized.

Copy link

@bit-scientist bit-scientist commented Apr 2, 2018

Thank you, it helped. One question. Should I do the same procedures every time I want to use Compute Engine?

@siliconberry

This comment has been minimized.

Copy link

@siliconberry siliconberry commented Apr 8, 2018

Thanks much. it was very useful and I'm able to logon to GCE within few mins, thanks to the detailed procedure.

@rimoune

This comment has been minimized.

Copy link

@rimoune rimoune commented Apr 26, 2018

Thanks feczo for this!
Is there any setting that needs particular attention?
I keep on getting "Network error: Connection timed out" when I try to connect via putty.
Cheers
R

@ankur07garg

This comment has been minimized.

Copy link

@ankur07garg ankur07garg commented May 3, 2018

Disconnected: No supported authentification methods available (server sent: public key). And when I logged into VM from Console ssh, strangely, I can not see any folder with name .ssh on machine. I a stuck on it from 1 week, please help

@samair

This comment has been minimized.

Copy link

@samair samair commented Jul 28, 2018

I scratched my head with the howto in Google page, this page is so wonderful.

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Aug 1, 2018

thank you!

@bmomartins

This comment has been minimized.

Copy link

@bmomartins bmomartins commented Oct 22, 2018

Disconnected: No supported authentification methods available (server sent: public key). And when I logged into VM from Console ssh, strangely, I can not see any folder with name .ssh on machine. I a stuck on it from 1 week, please help

Same issue here!

@uniqueperformtechsoft

This comment has been minimized.

Copy link

@uniqueperformtechsoft uniqueperformtechsoft commented Dec 9, 2018

Thanks a lot. Highly Appreciate it

@melwindmello

This comment has been minimized.

Copy link

@melwindmello melwindmello commented Dec 13, 2018

Thanks a ton for this article. Yes, the Google documentation on this is not as clear and straight forward as your post.

One thing I did different was configuring the SSH Keys at a Project Level (rather than at VM level) in the GCP Console.
There is an option 'Metadata' in the left navigation pane of 'Compute Engine'. I configured the SSH key in the SSH Keys tab.

Thanks again. Cheers

@dm00z

This comment has been minimized.

Copy link

@dm00z dm00z commented Dec 28, 2018

If anyone have trouble with:

Disconnected: No supported authentication methods available (server sent: public key).

Check if your instance have enable-oslogin set to TRUE. If it is, set it to FALSE then putty should be able to connect using your key.

@ali-cognitro

This comment has been minimized.

Copy link

@ali-cognitro ali-cognitro commented Jan 21, 2019

If anyone have trouble with:

Disconnected: No supported authentication methods available (server sent: public key).

Check if your instance have enable-oslogin set to TRUE. If it is, set it to FALSE then putty should be able to connect using your key.

Hi dm00z @dm00z

Still having this issue even enable-oslogin set to FALSE

@joaobrunoah

This comment has been minimized.

Copy link

@joaobrunoah joaobrunoah commented May 6, 2019

If anyone have trouble with:

    Disconnected: No supported authentication methods available (server sent: public key).

Check if your instance have enable-oslogin set to TRUE. If it is, set it to FALSE then putty should be able to connect using your key.

Genius! Thanks a lot, I've been trying to configure SSH in Google for a while, was almost giving up.

@harshan89

This comment has been minimized.

Copy link

@harshan89 harshan89 commented Sep 23, 2019

Followed every bit of your instruction when I double click on GCE it opens the terminal and shows "server refused our key"

Yes me too

@harshan89

This comment has been minimized.

Copy link

@harshan89 harshan89 commented Sep 23, 2019

If anyone getting "server refused our key" use following solution from arifrohim, It worked for me

https://github.com/arifrohim/rootaccess/blob/master/README.md

Cheers!!

@shivampatel16

This comment has been minimized.

Copy link

@shivampatel16 shivampatel16 commented Oct 7, 2019

I can not get the option to choose "GCE" under "Saved Sessions" in step 10 and 11. Any help to get that?

@thiwanka25

This comment has been minimized.

Copy link

@thiwanka25 thiwanka25 commented Dec 19, 2019

@ali-cognitro you save my day brother. Thanks

@mp

This comment has been minimized.

Copy link

@mp mp commented May 31, 2020

Followed every bit of your instruction when I double click on GCE it opens the terminal and shows "server refused our key"

This is a great tutorial, but step 5. is incomplete.

You need to paste your public key into your home directory's .ssh/authorized keys folder and then chmod it (log in using the Google console's HTML based SSH client). Follow both answers given in https://stackoverflow.com/questions/20249633/how-to-overcome-server-refused-our-key:

  1. user1789769's answer of pasting your public key into into .ssh/authorized keys (I had to create this file)
  2. m.nguyencntt's answer of chmodding .ssh/authorized keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.