How do I get root access to my Google Compute Engine VM instance, and also how can I log into my VM instance from my PC with a SSH client such as PuTTY?

I would also like to add that I have tried to do sudo for things that need root access to do those things, such as yum or wget. But it does not allow me to do sudo, it asks me for the root password but I do not know how, or where I would be able to get the root password.

  • Have you taken a look at ssh docs? If it's not working, please post the specific problem you're having. Once you're logged in using public key authentication, sudo should work without a password. Nov 23, 2014 at 20:50
  • Also, you can click the "SSH" button next to your VM instance in the Developers Console which will open a browser window and connect you directly to the VM without any configuration or extra software. Nov 27, 2014 at 19:12

2 Answers 2


AFAIK you cannot do an in-tty login as root via

su -

but I had no problem performing tasks as root using one-line sudo commands such as

sudo apt-get install make

on my Debian Wheezy VMs. IIRC, I was prompted for a password when I used sudo, but it accepted a blank password. I hadn't used a passphrase on my RSA key at that point yet, though -- it might link to that?

As for SSH-ing in using putty:

  1. Use puttygen to make a public/private SSH-2 RSA key pair
    1. Load puttygen
    2. Click 'Generate'
    3. Wiggle the mouse as it instructs
    4. When the key is ready, change the 'key comment' field to your login username (this is important, as it tells the VM which username to expect)
    5. Save the private key somewhere handy
    6. Copy all of the text out of the 'Public key for pasting into OpenSSH authorized_keys file' (Alt+P will select the whole text block) and save it somewhere handy

puttygen clip

  1. Create a new GCC VM instance, or edit an existing one.
    1. Click 'Show advanced options'
    2. Under 'SSH Keys', paste the entire contents of the public key into the 'Enter entire key data' box. The 'Username' field next to the box should change to your login name at this time. I don't think you need to click 'Add Key' unless you have another SSH key that you want to associate with the instance.

GCC clip

  1. Ensure that an external IP address is assigned to the instance (Ephemeral or Static both work -- the Ephemeral won't change as long as you keep the instance running, and may not change even if you take it down for short periods of time.)
  2. Further reconfigure the instance as desired and click 'Create' or 'Apply'

That should do it from the GCC side.

  1. Configure putty for SSH into the GCC VM
    1. Run putty
    2. Enter the external VM IP address (not the 10.x.x.x one) into the 'Host Name' field of the 'Session' settings (should be what you see first on loading putty)
    3. Under 'Connection\Data' enter your login username into the 'Auto-login username' field
    4. Under 'Connection\SSH\Auth' click 'Browse' next to 'Private key file for authentication' and locate the private key you saved above from puttygen.
    5. Under 'Session' type a nickname for the connection into the textbox under 'Saved Sessions' and then click 'Save' (this lets you not have to re-enter everything every time, by just selecting the nickname in the list and clicking 'Load')

putty clip

And I think that should do it from the putty side.

May have left something out, but I think that's the key steps.


Sudo has been working for me. I've found that Ubuntu has been more friendly over Debian (the default) for various things as well.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .