将公共ssh密钥添加到正在运行的AWS EC2实例 [英] Add a public ssh key to an AWS EC2 running instance

查看:687
本文介绍了将公共ssh密钥添加到正在运行的AWS EC2实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将朋友的公共SSH密钥添加到正在运行的AWS EC2实例.如何在Mac上执行此操作?

I would like to add my friend's public SSH key to a running AWS EC2 instance. How do I go about doing this on a Mac?

推荐答案

非常简单:

  1. SSH进入您的EC2实例
  2. 复制朋友的公共SSH密钥
  3. 将其添加到~/.ssh/authorized_keys

示例:

ssh ec2-user@your-ec2-instance # optional: -i ~/.ssh/YourPrivateKey.pem
echo "PASTE YOUR KEY HERE" >> authorized_keys

确保您朋友的钥匙上有描述性注释非常有用,这样,当您查看authorized_keys时,您不仅会看到钥匙和"user-1234 @ mac-local"或其他东西,评论-您的朋友"会更好.

It'd be useful to ensure your friend's key has a descriptive comment on it, so that when you view authorized_keys you don't just see the key and "user-1234@mac-local" or something as the comment - "YourFriend" would be better.

这篇关于将公共ssh密钥添加到正在运行的AWS EC2实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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