How to connect EC2 instance over SSH using Windows and Mac? | Visual Explanations

Pythoholic
26 Dec 201914:07

Summary

TLDRIn this informative tutorial, the host guides viewers through the process of connecting to an Amazon Web Services (AWS) EC2 instance using various tools and methods. Starting with the creation of an EC2 instance on AWS, the host then demonstrates how to connect to it via SSH with both Windows and Mac/Linux systems. For Windows 10, PowerShell and Command Prompt are used, while PuTTY and MobaXterm are recommended for older Windows versions. On Mac, the default terminal is utilized, and tools like Terminus are highlighted for a more user-friendly interface. The video also covers key management and permission settings to ensure secure connections. This comprehensive guide is designed to help users effectively manage and connect to their AWS instances.

Takeaways

  • 🚀 The video continues a tutorial series on connecting to AWS EC2 instances using SSH.
  • 💻 The presenter demonstrates how to create a new EC2 instance using Amazon Linux 2 AMI and a T2 micro instance, which is free tier eligible.
  • 🔑 A new key pair is created and downloaded for secure SSH access to the instance.
  • 🖥️ The video covers different methods to connect to the EC2 instance from both Windows and Mac/Linux systems.
  • 🛠️ For Windows 10 users, the presenter shows how to use PowerShell and Command Prompt to SSH into the instance after enabling SSH and setting the correct permissions on the key file.
  • 🔒 The importance of protecting the SSH key file with proper permissions is emphasized to ensure secure access.
  • 🔄 For older Windows versions, the use of PuTTY as an alternative to connect to the EC2 instance is suggested.
  • 🔗 The process of converting a PEM file to PuTTY's PPK format using PuTTYgen is explained.
  • 🌐 The video introduces MobaXterm as a tool for Windows users to connect to EC2 instances with a graphical interface.
  • 🍎 On Mac, the presenter uses the Terminal application to demonstrate the SSH connection process, including setting key permissions.
  • 🎨 Terminus is highlighted as a favorite tool for Mac users, offering a visually appealing UI for managing and connecting to SSH hosts.

Q & A

  • What is the main topic of the video?

    -The main topic of the video is about connecting to an AWS EC2 instance using different methods and tools on Windows, Linux, and Mac.

  • What are the steps to create a new EC2 instance in AWS as described in the video?

    -The steps include selecting the Amazon Linux 2 AMI, choosing the T2 micro instance which is free tier eligible, configuring the instance details without changes, adding a name tag, setting up a security group, and launching the instance with a new key pair.

  • What is the default username for connecting to an Amazon Linux AMI instance?

    -The default username for connecting to an Amazon Linux AMI instance is 'ec2-user'.

  • How can one check if SSH is enabled on Windows 10?

    -One can check if SSH is enabled on Windows 10 by opening PowerShell or Command Prompt and typing 'ssh' to see if there are options displayed or if there's an error like 'switch command not found'.

  • What is the process to connect to an EC2 instance using SSH on Windows 10?

    -The process involves opening PowerShell or Command Prompt, typing 'ssh' followed by the username 'ec2-user' and the instance's IP address, trusting the machine if prompted, and associating the previously downloaded SSH key to the command using the '-i' flag followed by the key file path.

  • Why is it important to protect the SSH key file when connecting to an EC2 instance?

    -It is important to protect the SSH key file because the key is used to authenticate your connection to the EC2 instance securely, and an unprotected key can pose a security risk.

  • What is the recommended permission setting for the SSH key file on Windows?

    -The recommended permission setting for the SSH key file on Windows is to allow modifying the file only by the user who owns it, by removing permissions for all other users and setting full control for the owner.

  • How can one connect to an EC2 instance using PuTTY on an older version of Windows?

    -One can connect to an EC2 instance using PuTTY by installing PuTTY, entering the hostname or IP address, specifying the username 'ec2-user', and using a PuTTY-compatible SSH key file (.PPK) which is created by importing the original .pem file using PuTTYgen.

  • What is MOBA Xterm and how is it used to connect to an EC2 instance?

    -MOBA Xterm is a terminal emulator for Windows that provides a graphical interface for SSH connections. It is used to connect to an EC2 instance by creating a new SSH session, entering the username and IP address, specifying the private key file, and establishing the connection.

  • What is the recommended permission setting for the SSH key file on Mac?

    -The recommended permission setting for the SSH key file on Mac is to change the permissions using 'chmod 400' command, allowing read access only to the owner of the file.

  • What is Terminus and how does it facilitate connecting to an EC2 instance?

    -Terminus is a terminal management tool with a graphical user interface. It facilitates connecting to an EC2 instance by allowing users to add a new host with a label and IP address, specify the username and SSH key, and connect with a single click.

Outlines

00:00

🖥️ AWS EC2 Instance Creation and SSH Connection Basics

The script begins with a greeting and an introduction to the tutorial series on AWS. The focus is on creating EC2 instances and connecting to them using SSH. The presenter demonstrates the process of launching a new Amazon Linux 2 instance with a T2.micro configuration, which is free tier eligible. They guide the audience through the steps of configuring the security group and creating a new key pair for SSH access. The presenter also explains how to check if SSH is enabled on Windows 10 and how to connect to the EC2 instance using the command prompt with the appropriate SSH command syntax. The importance of having the correct permissions set for the downloaded SSH key file is highlighted, and the presenter shows how to resolve permission issues to successfully establish an SSH connection.

05:02

🔐 Enhancing SSH Security and Connectivity with Tools

This paragraph delves into the details of securing the SSH key file and the process of connecting to an EC2 instance using different tools. The presenter explains how to change file permissions to ensure that only the owner can modify the SSH key file, which is crucial for security. They demonstrate how to use command prompt and PowerShell on Windows 10 for SSH connections. For users with older versions of Windows, the presenter suggests using PuTTY as an alternative. The process of converting an EC2 key from PEM format to PuTTY's PPK format is outlined, along with setting up a PuTTY session. Additionally, the presenter introduces MobaXterm, a tool that provides a graphical interface for SSH connections and includes features like file transfer and a local virtualized Linux machine environment.

10:03

🌐 Cross-Platform SSH Tools and Connection Techniques

The final paragraph covers SSH connection methods for different operating systems, focusing on Mac OS. The presenter uses the default terminal on Mac to demonstrate how to connect to an EC2 instance using SSH, emphasizing the need for proper permissions on the private key file. They also introduce Terminus, a popular SSH client with a user-friendly interface, and guide the audience through setting up a new host connection in Terminus. The presenter concludes by encouraging viewers to like and subscribe to the channel for more informative content, highlighting the educational value of the video.

Mindmap

Keywords

💡EC2 Instances

EC2 Instances refer to the virtual servers provided by Amazon Web Services (AWS) that can be used to host applications, run simulations, and perform other computing tasks. In the video, the creator discusses how to create and connect to EC2 instances, which is central to the theme of demonstrating cloud computing operations.

💡SSH Protocol

SSH, or Secure Shell, is a cryptographic network protocol for operating network services securely over an unsecured network. In the context of the video, SSH is the method used to securely connect to the EC2 instances, allowing for remote command-line access.

💡Windows 10

Windows 10 is an operating system developed by Microsoft, and in the video, it is mentioned as one of the platforms from which the creator demonstrates how to connect to an EC2 instance. The script includes specific steps for Windows 10 users to enable SSH and connect to AWS instances.

💡Amazon Linux 2 AMI

Amazon Linux 2 AMI stands for Amazon Machine Image, which is a pre-configured virtual machine image provided by AWS. The video script mentions selecting Amazon Linux 2 AMI as the base for the EC2 instance, highlighting the importance of choosing the right AMI for specific needs.

💡T2 Micro

T2 Micro is an instance type offered by AWS, which is part of the free tier and suitable for small, low to medium traffic websites and applications. The script refers to selecting T2 Micro as the instance type, indicating a cost-effective choice for beginners or small-scale projects.

💡Security Group

A security group in AWS is a virtual firewall that controls inbound and outbound traffic to EC2 instances. In the video, the creator configures a security group to allow SSH connections, which is crucial for establishing a secure connection to the instance.

💡Key Pair

In the context of AWS, a key pair refers to a public-private key pair that is used for authentication when connecting to an EC2 instance via SSH. The script details the process of creating and downloading a key pair, which is essential for secure access.

💡PuTTY

PuTTY is a free and open-source terminal emulator that is used to connect to servers via SSH, Telnet, and other protocols. The video mentions using PuTTY as a tool for older Windows versions to connect to Linux machines, showcasing an alternative method for those not using Windows 10.

💡MOBAXterm

MOBAXterm is a terminal software for Windows that provides an SSH client, Telnet client, and more. The script highlights MOBAXterm as a tool for creating SSH sessions, demonstrating its use for connecting to AWS EC2 instances.

💡Terminus

Terminus is a terminal emulator, system monitor, and network debugger for macOS. The video recommends Terminus as a favorite tool for the creator, showing how it can be used to connect to AWS EC2 instances with a user-friendly interface.

💡Permission

In computing, permission refers to the access rights granted to users or user groups to read, write, or execute files. The script discusses changing file permissions to ensure that only the owner can access the SSH key file, which is a security best practice when connecting to EC2 instances.

Highlights

Introduction to continuing the tutorial on connecting to EC2 instances using different operating systems and tools.

Creation of an 8 abreast EC2 instance and demonstration of connecting to it using SSH.

Explanation of launching a new EC2 instance with Amazon Linux 2 AMI and T2 micro for free tier eligibility.

Tagging the EC2 instance for identification and using a default security group.

Instructions on creating and downloading a new key pair for SSH access.

Visibility of instance launch progress and public IP address display.

Checking SSH availability on Windows 10 via PowerShell and Command Prompt.

Demonstration of connecting to an EC2 instance from Windows 10 using SSH.

Addressing permission denied errors and associating the correct SSH key.

Changing file permissions to protect the SSH key for secure connections.

Successfully logging into the EC2 instance using Command Prompt.

Using PuTTY as an alternative for older Windows versions to connect to Linux machines.

Conversion of the EC2 key from PEM to PPK format for PuTTY compatibility.

Introduction of MobaXterm as a tool for Windows users to connect to EC2 instances.

Demonstration of connecting to an EC2 instance using MobaXterm with SSH.

Switching to Mac OS and using the default Terminal to connect to an EC2 instance.

Using Terminus, a favorite tool for Mac users, to connect to EC2 instances with a beautiful UI.

Final thoughts and call to action for viewers to like, subscribe, and support the channel.

Transcripts

play00:00

hello everyone and welcome back to the

play00:01

channel once again and today on arrow to

play00:03

AWS we will continue from where we left

play00:05

yesterday we have created our 8 abreast

play00:08

ec2 instances and in today's episode we

play00:10

will see much more fun ways to connect

play00:12

to as such using Windows and using Linux

play00:16

or Mac and we look at some of the

play00:18

favorite tools that I have that I wanted

play00:20

to share with you so without wasting any

play00:22

more time let's get started

play00:24

[Music]

play00:28

[Applause]

play00:29

[Music]

play00:34

so the last thing what we had done is we

play00:36

had created our own a SS ec2 instance so

play00:39

it's quite fun isn't it

play00:41

so I would like to create once again one

play00:43

more new instance for you guys so that

play00:45

we can continue the flow and I will tell

play00:47

you the ways we can connect to this

play00:48

instance using the SSH protocol with the

play00:51

ways that we have for Windows and Mac so

play00:54

the first thing that we'll do is we'll

play00:55

create our instance or we launch an

play00:57

instance now so what we are going to do

play00:59

is we are going to follow the steps that

play01:02

we had followed last time as well so I

play01:04

will go ahead and select the Amazon

play01:06

Linux 2 AMI and I will select the T 2

play01:08

micro that's the free tier eligible and

play01:10

I will see the configuration instance

play01:13

everything is same I am NOT going to

play01:14

change anything so the tag that I'll add

play01:16

is first is name and this is the one

play01:20

that we will be using it so next we need

play01:22

to configure the security group I'll use

play01:24

a by default security group that is

play01:25

already available ok so let's search to

play01:28

my machine I will add the name as a

play01:31

description here so we can identify this

play01:34

easily so yeah just I'll click on launch

play01:36

I will create a new key pair

play01:38

so the key pair name is this and I will

play01:40

just download it and just you can just

play01:42

launch the instance right now so once

play01:45

you have done all these things you will

play01:46

be able to see the screen your instances

play01:48

are now launching so in a few minutes

play01:51

you'll be able to use these instances as

play01:53

well so this is the instance list that

play01:55

we have and I have created the new

play01:59

instance now so you can see the public

play02:01

IP that we have here is obviously

play02:02

displayed 13.1 86 2142 2 2 1 1 9 and the

play02:07

security group its launch wizard 1 that

play02:10

we had specified the key pair name as

play02:12

well and we will not name basically the

play02:15

pythonic mean that I had for the owner

play02:16

so it's obviously here so if you're

play02:19

currently using Windows 10 like cool

play02:20

then you can go to the powershell and

play02:22

you can just check whether you have SH

play02:25

enabled or not so if you get this as

play02:27

such and you get a lot of options like

play02:28

this then you have such and you can go

play02:31

to the command prompt as well and check

play02:33

the same so if you get the same and both

play02:36

of them then your SH is enabled and if

play02:38

you get something like a switch command

play02:40

not found or something then probably you

play02:42

don't have a switch and even

play02:44

your machine maybe you are using an

play02:45

older version of Windows but now what we

play02:47

are going to do is we are going to

play02:48

connect to this machine so on Windows 10

play02:51

what we are going to do is we're going

play02:52

to just type SSH

play02:53

then the username and the IP address so

play02:57

username for the Amazon Linux AMI -

play02:59

basically it will always be like ec2 -

play03:02

user so you just need to type hey c2 -

play03:04

user and at the rate the IP address so

play03:07

I'll just copy the IP address and I'll

play03:11

paste it it is asking for us to

play03:15

basically trust this machine so what I'm

play03:18

going to do is I will just trust it okay

play03:20

so it's permission denied because I

play03:22

haven't added the key that I had

play03:23

provided previously or I had downloaded

play03:25

that so now what I'm going to do is I'm

play03:27

going to associate that key and attached

play03:29

to this particular execution command

play03:32

mean it will give the option of - I

play03:34

after - line you need to just mention

play03:36

the path of that particular file name so

play03:39

I have the file with me here and what

play03:41

I'm going to do is I'm going to just

play03:42

copy the file path and I'm going to

play03:43

specify it here so I'm going to specify

play03:45

that command - I the path of the file of

play03:48

that particular SSH key and then they

play03:50

username at the rate the IP address okay

play03:53

so no such first nan so what I'm going

play03:55

to do I'm just going to I iterate to the

play03:57

particular folder path that I have okay

play04:01

so I'll just execute the command once

play04:03

again so what it is selling is

play04:07

unprotected private key file so what you

play04:09

need to understand is whenever you are

play04:11

trying to access a particular SH

play04:13

instance using a such protocol the key

play04:16

that you are using for connecting it to

play04:18

the machine using SSH should be

play04:21

protected properly so what do you what

play04:23

are you going to do is you want to

play04:24

protect it so we'll see what are the

play04:26

permissions available for that file that

play04:28

we have so this is the properties of

play04:30

that particular file so you're going to

play04:32

click on security so you can see here

play04:34

that these are the few users that are

play04:35

already there they are able to actually

play04:38

manipulate the file so what I'm going to

play04:40

do is I'm going to allow the permission

play04:42

for modifying this file only to myself

play04:44

and for my user itself so what I'm going

play04:47

to do is I'm going to go to advanced and

play04:48

I'm going to remove all the permission

play04:50

from other people that are currently

play04:52

using it so I'll just remove this

play04:57

remove this so what it is telling is you

play05:01

cannot remove system because this object

play05:03

is inherited permissions from its parent

play05:05

so we'll remove the inheritance first so

play05:08

you click on this one click on this

play05:09

remove all in this I'm going to add

play05:13

myself so now once I have this I can

play05:17

just add myself I will give myself the

play05:19

full control and click on this so now

play05:22

only I have the access ok so what I did

play05:24

is I removed the inheritance from all of

play05:26

them and just I added myself so once you

play05:29

have done this you can click on apply

play05:30

click on ok and that's it that's what we

play05:33

need to make it protected and we are

play05:35

going to run the same command once again

play05:37

and it will work yes see we have

play05:40

successfully logged into the machine and

play05:42

if you do the same thing using command

play05:44

prompt also it will work so I will open

play05:46

the command prompt and if I type here so

play05:48

now I'll execute the same command again

play05:49

and you will be able to access the

play05:51

instance yes it's quite fun isn't it see

play05:57

I'm able to access it so these are the

play05:59

two ways that I actually told you right

play06:01

now and this pretty important when you

play06:03

using Windows 10 or Windows basically to

play06:05

change the permission this is really

play06:07

important most of the times we actually

play06:09

don't know how to do this but now with

play06:11

this tutorial maybe it will help you it

play06:13

has helped me as well so if you really

play06:15

liked it then hit the like button right

play06:17

now but moving forward but if you are

play06:19

using any older version of Windows then

play06:21

you can probably use putty to connect to

play06:23

your Linux machine so this also helps

play06:26

you connect to the last mission using s

play06:28

switch so what are you going to do is

play06:29

once you have installed putty you see

play06:32

your hostname or IP address here is

play06:34

where we will be entering the hostname

play06:37

ec2 user at the rate the IP address that

play06:40

we have so I will go back here and I

play06:42

will copy the IP address I've copied it

play06:46

and what I'm going to do is I'll just go

play06:49

ahead and paste it so once I've done

play06:50

this I'll just give it a name ec2

play06:55

instance okay and I'm going to save it

play06:59

so if you see the key that we can

play07:01

download it before it is a PM file but

play07:03

we need to have a secure shell key that

play07:06

beastly is compatible with putty

play07:10

so we'll create a putty compatible file

play07:12

so for that I need to open the putty

play07:15

kitchen so you can go ahead and check

play07:18

for party kitchen so once you get the

play07:20

kitchen what do you need to do is you

play07:22

need to just reload the private key that

play07:24

you have go to the desired folder that

play07:28

you had already placed your file click

play07:31

on all types ok select the drop down and

play07:34

click all files and you can just select

play07:36

the ec2 key dot VM file successfully

play07:40

imported foreign key ok to use this you

play07:42

need to just save it and say a private

play07:44

key command and use it and put his own

play07:46

format ok once you just click this then

play07:49

you can just save the private key so are

play07:53

you sure you want to save this key

play07:54

without a passphrase to protect it yes I

play07:57

would definitely want to save it without

play07:59

a passphrase but if you want additional

play08:01

security basically you can add a

play08:03

passphrase to that but I am NOT going to

play08:05

do it so I'll just click on yes and I'll

play08:08

save it as ec2 - key dot VPK auto putty

play08:14

private key so once I've saved it what

play08:19

I'm going to do is I have selected this

play08:21

so you see the categories your right go

play08:24

to the connections part you see a switch

play08:26

click on this and expand it and you see

play08:30

author here what you're going to do is

play08:32

you're going to browse for that file

play08:35

that we had just created click on that

play08:38

and select open once you have done that

play08:41

don't select or don't click on open

play08:44

right now go to sessions click on ec2

play08:47

and save it now double click on this see

play08:54

it's as easy as and it's as simple as

play08:58

possible so once you have done the part

play09:01

where you have converted that p.m. file

play09:03

to PPK file that's when you can use

play09:05

buttons because if you just import it

play09:08

and you try to run it it will not work

play09:10

the next tool that I wanted to share for

play09:12

Windows is MOBA X term that's also

play09:14

pretty neat tool I have been using it

play09:16

since a long time when I was working

play09:19

with Windows but when I jumped into Mac

play09:21

I started using dominus so here it is

play09:24

also very simple and pretty clean setup

play09:27

that you have so once you have installed

play09:28

MOBA X term I'll give you the link in

play09:30

the description below you can just

play09:32

download it as well so you get to have a

play09:34

very good interface here the graphical

play09:36

interface so what you want to do is if

play09:38

you want to create a session or SS

play09:40

session or a remote session you can just

play09:43

click on this click on SSH ok then enter

play09:48

the same way that you had entered in

play09:49

party you see - - user at the rate the

play09:54

IP address and just copy it once again

play09:58

so to stop and what happens here is you

play10:02

can either give it here or you can just

play10:05

specify the username by default that it

play10:09

will be logged into so specify user name

play10:11

and you can just type it here and you

play10:13

can assign the port as well and you need

play10:15

to mention the private key here so you

play10:17

need to go to advanced SSH and then you

play10:20

CA use private key option click on this

play10:23

checkbox to activate it and browse for

play10:26

the file so go to desktop means I have

play10:28

my file on the desktop so and just use

play10:31

the private key ok so once these

play10:34

settings have been entered then you are

play10:36

good to go you can just click OK and yes

play10:40

we have connected to the ec2 instance

play10:43

using mobile X term so this is pretty

play10:46

neat actually you will have a session

play10:48

here and you can as well drop files and

play10:51

download files as well using the option

play10:53

there is pretty cool to have something

play10:56

like this

play10:56

and the best part about Globex term is

play10:58

that you get a local instance where you

play11:01

wait to play with a local instance of

play11:04

virtualized Linux machine so if I type

play11:07

here

play11:08

unless it'll work so this is pretty neat

play11:10

so welcome to Mack everyone so Mac I'm

play11:13

using the by default terminal like Mac

play11:15

provides me and I'm just going to

play11:17

execute the same command that I had

play11:19

executed but I'll use the SSH command

play11:21

here which I executed on Windows 10 on

play11:23

the partial so let's go ahead and I'll

play11:26

provide the destination for that and

play11:28

I'll add the private key just I'm going

play11:31

to allow it and the username easy to

play11:33

have an user and copy the IP address and

play11:36

I will paste it okay

play11:37

yes I'm going to allow this oh okay

play11:42

we face the same problem here protected

play11:44

unprotected private key file so what we

play11:47

are going to go is we are going to

play11:48

change the permission for the private

play11:49

key that we had and we are going to

play11:51

allow it for access only to myself so

play11:54

nitrate to the file and I'll check the

play11:56

permissions LS - alt R and yes it has

play12:00

write access for others in groups as

play12:03

well so I will go to change it I will

play12:05

see smooth 0 4 0 0 and allow it to just

play12:09

myself the read permission only for

play12:11

myself so once you have set the

play12:13

permissions and this is pretty good to

play12:14

go then you can just execute the same

play12:16

again and well I think we should be able

play12:20

to connect yes we are and let's move on

play12:22

to the next one so the next important

play12:24

tool and my one of my favorite tools

play12:26

that I wanted for you guys to also use

play12:29

was terminus I have been using it since

play12:31

long time once since the time that I

play12:33

have been using Mac so you can just type

play12:35

in terminus and you can download it I

play12:36

will provide you the landing link in the

play12:38

description below you can download it

play12:40

and what you get with terminus is a

play12:42

beautiful UI so first of all you need to

play12:45

continue without a count so not a

play12:47

problem you don't need to login into

play12:48

this so once you enter the console what

play12:51

you want to see is a beautiful UI and

play12:53

the way we need to add is click on new

play12:55

host and add the label for the instance

play12:58

that you want it's like giving the name

play13:00

for that particular instance and just

play13:02

add the IP address now you don't have to

play13:04

worry about groups leave that come down

play13:07

and you have mentioned as such that's

play13:09

cool poor tornado is by default you just

play13:12

need to give the username ec2 - user and

play13:14

you need to pass the key the H key that

play13:16

we had click on plus keys and then give

play13:18

it a label like ec2 - key or something

play13:21

no passphrase just browse the file once

play13:24

you have done that just you need to

play13:26

click on save so that's it and thomas

play13:28

provides you a beautiful theme as well

play13:30

like i will be going with the basic

play13:32

theme and that's it nothing more to do

play13:34

just click on save so once you have this

play13:36

just click on connect with a switch

play13:38

accept it that's it that's it you are

play13:40

good to go you are able to connect to

play13:41

the line of so am I so I hope this video

play13:43

was as informative and as enjoyable as

play13:46

it gets so if you did enjoy please hit

play13:48

the like button and if you haven't

play13:50

subscribed already where you doing man

play13:51

please subscribe to the channel and uh

play13:54

then sign off

play13:57

[Music]

play14:00

[Applause]

play14:01

[Music]

Rate This

5.0 / 5 (0 votes)

Related Tags
AWSEC2SSHWindowsMacLinuxSecurityTutorialConnectivityTools