Google Cloud-通过私钥访问Linux VM [英] Google Cloud - accessing Linux VM via private key

查看:89
本文介绍了Google Cloud-通过私钥访问Linux VM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Google云中创建了一个Linux VM,现在我正尝试通过SSH访问该VM.

I have created a linux VM in Google cloud, and right now I am trying to access the VM through SSH.

我能够SSH到服务器,如果我通过界面登录到控制台,但是我试图生成可使用的便携式私钥文件(pem)可以从任何地方将其远程连接到服务器.

I am able to SSH to the server, if I am loged-in to the console via the interface, However I am trying to generate a portable private key file (pem) which I can use it to remote to the server from anywhere.

在创建VM的过程中,我可以在AWS或Azure上轻松实现这一目标,但在GC上似乎并非如此.

I can achieve this easily on AWS, or Azure during the VM creation, but this doesn't seem to be the case on GC.

推荐答案

我理解您的意思,但Google会自动完成.

I understand what you mean, but google do it in a bit more automatically.

任何本地计算机中,首先获取具有正确访问权限的服务帐户json.

In any local computer, first get a service-account json with right access.

通过

gcloud auth activate-service-account --key-file=KEY_FILE.json

然后

gcloud compute config-ssh [--ssh-config-file=SSH_CONFIG_FILE] [--ssh-key-file=SSH_KEY_FILE]

您可能已经有ssh文件,但是如果您只是让gcloud生成它就可以了.

You may already have ssh file, but that's fine if you simply let gcloud to generate it.

最后,您可以通过以下方式从这台计算机SSH到任何计算引擎中,

Finally you can ssh into any compute engine from this computer by,

gcloud compute ssh [USER@]INSTANCE

下一次在同一台计算机上时,您只需使用gcloud compute ssh即可再次访问它.

While, for next time in the same computer, you just need to use gcloud compute ssh to access it again.

这篇关于Google Cloud-通过私钥访问Linux VM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆