Amazon recently launched the ability to upload your own ssh public key to EC2 so that it can be passed to new instances when they are launched. Prior to this you always had to use an ssh keypair that was generated by Amazon.
The benefits of using your own ssh key include:
-
Amazon never sees the private part of the ssh key (though they promise they do not save a copy after you downloaded it and we all trust them with this)
-
The private part of the ssh key is never transmitted over the network (though it always goes over an encrypted connection and we mostly trust this)
-
You can now upload the same public ssh key to all EC2 regions, so you no longer have to keep track of a separate ssh key for each region.
-
You can use your default personal ssh key with brand new EC2 instances, so you no longer have to remember to specify options like
-i EC2KEYPAIR
in everyssh
,scp
,rsync
command.
If you haven’t yet created an ssh key for your local system, it can be done with the command:
ssh-keygen
You can accept the default file locations, and I recommend using a secure passphrase to keep the key safe.
Here are some sample commands that will upload to all existing regions your personal ssh public key from the default file location on Ubuntu, giving it an EC2 keypair name of your current username. Adjust to suit your preferences:
keypair=$USER # or some name that is meaningful to you
publickeyfile=$HOME/.ssh/id_rsa.pub
regions=$(ec2-describe-regions | cut -f2)
for region in $regions; do
echo $region
ec2-import-keypair --region $region --public-key-file $publickeyfile $keypair
done
When you start new instances, you can now specify this new keypair name and EC2 will provide the previously uploaded public ssh key to the instance, allowing you to ssh in. For example:
ec2-run-instances --key $USER ami-508c7839
[...]
ec2-describe-instances i-88eb15e5
[...]
ssh ubuntu@ec2-184-73-107-172.compute-1.amazonaws.com
Don’t forget to terminate the instance if you started one to test this.
[Update]
Based on a Twitter question, I tested uploading a DSA public ssh key (instead of RSA) and got this error from Amazon:
Client.InvalidKeyPair.Format: Invalid DER encoded key material
I don’t see why DSA would not work since it’s just a blurb of text being stored by EC2 and passed to the instance to add to $HOME/.ssh/authorized_keys
but there you have it.
相关推荐
Users only pay for what they use and can store and retrieve any amount of data at any time over the Internet, which attracts Hadoop users who run clusters on EC2. The book starts by showing you how ...
该代码的Android应用程序。 良好的代码,以Dropbox的优势。
化妆品培训材料.pptx.baiduyun.uploading.cfg
Uploading-Images-To-Node-Dynamically:源代码
Uploading Desktop
带用户数据的Terraform-EC2- 使用Terraform用用户数据配置ec2实例 先决条件: 从链接下载Terraform并在Linux机器中进行设置。 (这里我使用的是ec2实例)在实例中配置aws cli。 首先我们需要创建一个目录 mkdir ec2...
化妆品工艺.pptx.baiduyun.uploading.cfg
ACCESS_TOKEN=5607b93462c0a7e6b07d4e1892493e92d13c94e2391f80131edf0853c1e05b29e968rb2w265589cftu9 跑 $ python working_with_the_vk_api.py.py 你会看见 组中的漫画。 如果没有必需的组权限,或者获取ACCESS_...
Uploading and Downloading Files in Web Dynpro Java
Uploading and Viewing Files the Easy Way
This book will teach you how to start with “Hello World” and ends with uploading or controlling your Sensor data’s from all over the world. why you are still waiting for? Go ahead and enjoy the ...
Laravel开发-cloud-uploading-service 基于lumen5.6/laravel开发了云上传服务,包括aliyun oss、qcloud cos。包括图片、文件和其他碎片上载
a highly efficient proprietary HttpModule, which enables uploading of files with size up to 2GB, while allocating a minimum amount of server memory. UI control for single- and multi-file uploads, ...
化妆品卫生安全培训.pptx.baiduyun.uploading.cfg
一个基于C#+ASP.NET实现的.NET Image Uploading图片上传程序例子代码。
化妆品品牌调研概述课件.pptx.baiduyun.uploading.cfg
npm install --save react-images-uploading 纱 yarn add react-images-uploading 用法 您可以在此处查看基本演示: Javascript: https : //codesandbox.io/s/react-images-uploading-demo-u0khz 打字稿: ...
例如C:\Program Files\JetBrains\PyCharm 2017.2.3这里面找到并且 删掉skeletons文件夹,重新启动再配置远程环境就好了 以上这篇解决pycharm 远程调试 上传 helpers 卡住的问题就是小编分享给大家的全部内容了,...
file-uploading-with-php-and-mysql
化妆品化学聊城大学化学化工学院.pptx.baiduyun.uploading.cfg