简体   繁体   中英

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.

The students will have to set up EC2 Ubuntu instances and connect to them.

What is the easiest way to set up SSH for Windows XP-7?

I've tried PuTTY but Puttygen can only convert the public key to putty format if I manually add newlines in a text editor. This is too involved for the class of 80.

I've tried OpenSSH but I can't seem to find the correct permissions for the public key file. On Mac OS/Linux it's just chmod 600 .

Is there a decent SSH client that supports Amazon's key format that I can set up easily?

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

Another possible solution is to use PuTTY but follow Amazon's guide for doing so. 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.

  1. Install PuTTY .
  2. Follow Amazon's guide for converting your PEM file to the PuTTY PPK format.
  3. Connect to your server!

As for newlines, maybe you need to run unix2dos or some other program that will fix that for you?

Step1: Download the keypair

第1步:

The download will create a .pem file on your local system. It contains a private key that you can use to connect to the EC2 instance via SSH

Step 2: Launch your linux instance

在此处输入图片说明

Copy the public ip address for the future use to connect the linux instance

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

Step 4: Execute the PuttyGen exe and load the private key(the pem file you have downloaded while launching the instance)

在此处输入图片说明

Step 5: Save the private key, it will give the .ppk file which will be used to connect the linux instance

在此处输入图片说明

Step 6: Download and install the Putty software, open the putty, and paste the public ip address which you copied from the linux instance

在此处输入图片说明

Step 7: Now load the .PPK file which we have saved

在此处输入图片说明

Step 8: Choose yes from the alert window在此处输入图片说明

Step 9: Login as ec-user在此处输入图片说明

If anybody's looking for windows 10 solution.
In Windows 10, you can use 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.
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. You can open power shell at any location by print powershell in the nevigation bar and press enter. enter image description here

1.reset premission:

icals.exe key.pem /reset 

2.check the current user id

whoami

3.add permision to specific user id

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

4.remove permission of other user

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

Now it should work.

If anybody's looking for windows 10 solution.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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