Google Cloud: Compute VM Instances

2019-02-02 00:08发布

How do I get root access to my Google 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.

7条回答
The star\"
2楼-- · 2019-02-02 00:49

How do I use sudo to execute commands as root?

(splitting this off from the other answer since there are multiple questions within this post)

Once you connect to your GCE VM using PuTTY or gcloud compute instances ssh or even clicking on the "SSH" button on the Developers Console next to the instance, you should be able to use the sudo command. Note that you shouldn't be using the su command to become root, just run:

sudo [command]

and it should not prompt you for a password.

If you want to get a root shell to run several commands as root and you want to avoid prefixing all commands with sudo, run:

sudo su -

If you're still having issues, please post a new question with the exact command you're running and the output that you see.

查看更多
登录 后发表回答