简体   繁体   English

SSH 到 EC2 linux 实例来自 Windows

[英]SSH to EC2 linux instance from Windows

I'm setting up a "data analysis on the cloud" class and most of the students will probably be using Windows.我正在设置“云端数据分析”class,大多数学生可能会使用 Windows。

The students will have to set up EC2 Ubuntu instances and connect to them.学生必须设置 EC2 Ubuntu 实例并连接到它们。

What is the easiest way to set up SSH for Windows XP-7?为 Windows XP-7 设置 SSH 的最简单方法是什么?

I've tried PuTTY but Puttygen can only convert the public key to putty format if I manually add newlines in a text editor.我已经尝试过 PuTTY,但如果我在文本编辑器中手动添加换行符,Puttygen 只能将公钥转换为 putty 格式。 This is too involved for the class of 80.这对于 80 的 class 来说太过分了。

I've tried OpenSSH but I can't seem to find the correct permissions for the public key file.我尝试过 OpenSSH,但似乎找不到公钥文件的正确权限。 On Mac OS/Linux it's just chmod 600 .在 Mac OS/Linux 上,它只是chmod 600

Is there a decent SSH client that supports Amazon's key format that I can set up easily?是否有一个像样的 SSH 客户端支持我可以轻松设置的亚马逊密钥格式?

亚马逊网络服务为您提供的 .pem 文件由 openssh 客户端实现支持,但对于直接使用 .pem 文件而不使用 puttygen.exe 进行转换的基于 Windows 的客户端,请查看Bitvise Tunnelier

Another possible solution is to use PuTTY but follow Amazon's guide for doing so.另一种可能的解决方案是使用PuTTY,但请按照亚马逊的指南进行操作。 I found some other guide's that weren't as clear in the steps but I was able to get PuTTYgen to work correctly when I used their guide.我发现其他一些指南在步骤中不太清楚,但是当我使用他们的指南时,我能够让 PuTTYgen 正常工作。

  1. Install PuTTY .安装腻子
  2. Follow Amazon's guide for converting your PEM file to the PuTTY PPK format.按照亚马逊的 指南将您的 PEM 文件转换为 PuTTY PPK 格式。
  3. Connect to your server!连接到您的服务器!

As for newlines, maybe you need to run unix2dos or some other program that will fix that for you?至于换行符,也许您需要运行unix2dos或其他一些程序来解决这个问题?

Step1: Download the keypair第一步:下载密钥对

第1步:

The download will create a .pem file on your local system.下载将在您的本地系统上创建一个 .pem 文件。 It contains a private key that you can use to connect to the EC2 instance via SSH它包含一个私有密钥,您可以使用它通过 SSH 连接到 EC2 实例

Step 2: Launch your linux instance第 2 步:启动您的 linux 实例

在此处输入图片说明

Copy the public ip address for the future use to connect the linux instance复制公网ip地址,供以后连接linux实例使用

Step 3: Download puttyGen from https://the.earth.li/~sgtatham/putty/latest/w32/puttygen.exe第 3 步:https://the.earth.li/~sgtatham/putty/latest/w32/puttygen.exe下载 puttyGen

Step 4: Execute the PuttyGen exe and load the private key(the pem file you have downloaded while launching the instance)第四步:执行PuttyGen exe并加载私钥(启动实例时下载的pem文件)

在此处输入图片说明

Step 5: Save the private key, it will give the .ppk file which will be used to connect the linux instance第 5 步:保存私钥,它将提供用于连接 linux 实例的 .ppk 文件

在此处输入图片说明

Step 6: Download and install the Putty software, open the putty, and paste the public ip address which you copied from the linux instance第六步:下载安装Putty软件,打开putty,粘贴你从linux实例复制的公网IP地址

在此处输入图片说明

Step 7: Now load the .PPK file which we have saved第 7 步:现在加载我们保存的 .PPK 文件

在此处输入图片说明

Step 8: Choose yes from the alert window步骤 8:从警报窗口中选择是在此处输入图片说明

Step 9: Login as ec-user第 9 步:以 ec 用户身份登录在此处输入图片说明

If anybody's looking for windows 10 solution.如果有人正在寻找 Windows 10 解决方案。
In Windows 10, you can use powershell.在 Windows 10 中,您可以使用 powershell。 Use above command.使用上面的命令。

ssh -i \..\location-to-pem-file.pem ubuntu@X.X.XXX.XXX

If ssh is not supported in your windows 10 machine, follow this url for installation.如果您的 Windows 10 机器不支持 ssh,请按照此url进行安装。
I used it and suggested the same.我使用它并建议相同。

I borrowed the method giving in this video.我借用了这个视频中给出的方法。 https://youtu.be/P1erVo5X3Bs Open power shell and run below commands. https://youtu.be/P1erVo5X3Bs打开电源 shell 并运行以下命令。 You can open power shell at any location by print powershell in the nevigation bar and press enter.您可以通过在导航栏中打印 powershell 并按 Enter,在任何位置打开电源 shell。 enter image description here在此处输入图像描述

1.reset premission: 1.重置前提:

icals.exe key.pem /reset 

2.check the current user id 2.查看当前用户id

whoami

3.add permision to specific user id 3.添加权限到特定的用户ID

icacls.exe key.pem /grant:r "YOUR USER ID GIVEN BY WHOAMI"

4.remove permission of other user 4.删除其他用户的权限

icacls.exe .\ec2.pem /inheritance:r  

Now it should work.现在它应该可以工作了。

If anybody's looking for windows 10 solution.如果有人在寻找 windows 10 解决方案。

icacls.exe .\Desktop\xxxx.pem /reset
icacls.exe .\Desktop\xxxx.pem /grant:r "$($env:USERNAME):(r)"
icacls.exe .\Desktop\xxxx.pem /inheritance:r
ssh -i .\Desktop\xxxx.pem ec2-user@54.229.xxx.x

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM