如何将SSH密钥添加到Google Cloud Compute Engine VM Linux实例? [英] How do I add a SSH key to Google Cloud Compute Engine VM Linux instance?

查看:88
本文介绍了如何将SSH密钥添加到Google Cloud Compute Engine VM Linux实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Google Cloud Platform中运行的Linux VM实例.我尝试将我的公钥复制到〜/.ssh/authorized_keys ,并且可以成功地SSH到我的VM.

I have a Linux VM instance running in Google Cloud Platform. I tried to copy my public key to ~/.ssh/authorized_keys and I can successfully SSH to my VM.

但有时〜/.ssh/authorized_keys 已刷新,我不得不再次复制公钥.每次添加公钥确实很痛苦.如何永久添加公钥?

But sometimes ~/.ssh/authorized_keys is flushed and I have to copy the public key again. It is really a pain to add public key every time. How do I add a public key permanently?

推荐答案

文件消失"的一个可能原因是,每次重新加载实例时,都会从同一VM映像重新加载该文件,而不会包含文件.检查这些事件是否与实例重新加载相关联,以及主目录中的其他文件是否也消失了,如果这样做,则可能是罪魁祸首.如果是这样,我可以看到几种可能的方法:

One possible reason for which the file would "disappear" would be that every time the instance is reloaded it is reloaded from the same VM image, which doesn't contain the file. Check if the occurences are correlated with the instance reloading and if other files in your home dir disappear as well, if they do that's likely the culprit. If so I can see a couple of possible approaches:

  • 〜/.ssh/authorized_keys 文件(当然还有您的用户目录和主目录配置)包含到

  • include the ~/.ssh/authorized_keys file (and, of course, your user and home directory configurations) into a custom VM image that you could then use to boot your instances from

永久磁盘可以在实例重新加载后幸存下来

configure your home directory on a persistent disk which would survive across instance reloads

这篇关于如何将SSH密钥添加到Google Cloud Compute Engine VM Linux实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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