aws windows linux同时,AWS EC2笔记之一 如何通过Putty连接AWS Linux系统

Connecting to Linux/UNIX Instances from Windows Using PuTTY

To connect to your Linux/UNIX instance from a Windows computer, use

an SSH client. The following instructions explain how to use PuTTY,

a free SSH client for Windows computers.

Prerequisites

Enable SSH traffic—Open the instance's

SSH port

Before you try to connect, ensure that your Amazon EC2 instance

accepts incoming SSH traffic (usually on port 22). For more

information, see

Instance ID—Get the ID of your Amazon

EC2 instance

Retrieve the Instance ID of the Amazon EC2 instance you want to

access. The Instance ID for all your instances are available in the

AWS Management Console or through the CLI

command

Instance's public DNS—Get the public

DNS of your Amazon EC2 instance

Retrieve the public DNS of the Amazon EC2 instance you want to

access. You can find the public DNS for your instance using the AWS

Management Console or by calling the CLI

command ec2-describe-instances.

The format of an instance's public DNS is

ec2-w-x-y-z-compute-1.amazonaws.com where w, x, y, and z each

represents a number between 0 and 255 inclusive.

Private key—Get the path to your

private key

You'll need the fully qualified path of the private key file

associated with your instance. For more information on key pairs,

see

Getting

PuTTY

To download and

install PuTTY

Other tools in the PuTTY suite are

PuTTYgen, a key generation program, and pscp, a secure copy command

line tool. The different PuTTY tools are separate applications. You

can install them separately or install the entire suite with a

simple Windows installer. The following instructions assume you've

installed the entire suite and can access all the components from

the Windows Start menu.

Converting

Your Private Key

PuTTY does not natively support the

private key format generated by Amazon EC2. Fortunately, PuTTY has

a tool called PuTTYgen, which can convert keys to the required

PuTTY format.

To convert your

private key

Start PuTTYgen (for example, from

the Start menu,

click All Programs > PuTTY >

PuTTYgen).

Click Load and browse to the

location of the private key file that you want to convert

(e.g., GSG_Keypair.pem).

By default, PuTTYgen displays only files with

extension .ppk; you'll

need to change that to display files of all types in order to see

your .pem key

file. The private key file must end with a newline character or

PuTTYgen cannot load it correctly.

a4c26d1e5885305701be709a3d33442f.png

Select

your .pem key

file and click Open.

PuTTYgen displays the following

message.

a4c26d1e5885305701be709a3d33442f.png

When you click OK, PuTTYgen displays

a dialog box with information about the key you loaded, such as the

public key and the fingerprint. The keys that Amazon EC2 generates

are 1024-bit SSH-2 RSA keys.

Click Save private

key to save the key in PuTTY's format.

PuTTYgen asks if you want to save the key without a passphrase.

a4c26d1e5885305701be709a3d33442f.png

Click Yes.

Note

A passphrase

on a private key is an extra layer of protection, so even if your

private key is discovered, it will not be usable without the

passphrase. The downside to using a passphrase is that it makes

automation harder because human intervention is needed to log on to

an instance, or copy files to an instance. For this exercise, we're

not using a passphrase.

Use the same name for the key that

you used for the key pair (for example, GSG_Keypair). PuTTY

automatically adds the .ppk file

extension.

Your private key is now in the

correct format for use with PuTTY. You can now connect to your

instance using PuTTY's SSH client.

Connecting

Using PuTTY SSH

You'll connect by starting a PuTTY

SSH session.

To use SSH to

connect

If you've launched a public AMI that

isn't one that you created yourself, run

the ec2-get-console-output command

on your local system (not on the instance), and locate

the SSH HOST KEY

FINGERPRINTS section. For more information,

see ec2-get-console-output in

the Amazon Elastic Compute

Cloud Command Line Reference.

C:\>ec2-get-console-output instance_id

...

ec2: -----BEGIN SSH HOST KEY FINGERPRINTS-----

ec2: 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00

/etc/ssh/ssh_host_key.pub

ec2: 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00

/etc/ssh/ssh_host_rsa_key.pub

ec2: 1024 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00

/etc/ssh/ssh_host_dsa_key.pub

ec2: -----END SSH HOST KEY FINGERPRINTS-----

...

Note the fingerprints so that you

can compare them to the fingerprints of the instance.

Start PuTTY (from

the Start menu,

click All Programs > PuTTY >

PuTTY).

A dialog box opens with a Category menu on

the left side. On the right side, the basic options for your PuTTY

session are displayed.

In the Host

Name field, enter the public DNS name of

your instance (available through the AWS Management Console or

the ec2-describe-instancescommand).

You can optionally prefix the DNS name

with ec2-user@ to

automatically log in with superuser privileges when the session

opens.

a4c26d1e5885305701be709a3d33442f.png

In the Category menu,

under Connection,

click SSH, and

then Auth.

The options controlling SSH authentication are displayed.

Click Browse and navigate to

the PuTTY private key file you generated in the preceding

section.

a4c26d1e5885305701be709a3d33442f.png

Click Open.

An SSH session window opens and PuTTY displays a security alert

asking if you trust the host you're connecting to.

Important

If you've

launched a public AMI, verify that the fingerprint in the security

alert matches the fingerprint from the output of

the ec2-get-console-output command.

If it doesn't, someone might be attempting a "man-in-the-middle"

attack.

Click Yes.

In the SSH session window, log in as

root (or ec2-user) if you didn't as part of starting the SSH

session.

Note

Some AMIs let

you log in as root, but some require you to log in with the

username ec2-user. For log in information for your chosen AMI,

contact your AMI provider directly or go

to Amazon Machine

Images(AMIs) page, then locate and click your

AMI on the list.

Note

If you

specified a passphrase when you converted your private key to

PuTTY's format, you must provide that passphrase when you log in to

the instance.

Transferring Files with PSCP

The PuTTY Secure Copy Client (PSCP)

is a command-line tool that lets you transfer files between your

Windows computer and your Linux/UNIX instance.

To use PSCP, you'll need the private

key you generated in Converting Your Private Key. You'll

also need the public IP address of your Linux/UNIX instance.

The following example transfers the

file sample_file.txt from

a Windows computer to the /usr/local directory

on a Linux/UNIX instance:

C:\>pscp -i C:\GSG_Keypair.ppk C:\sample_file.txt root@ec2-184-72-204-112.compute-1.amazonaws.com:/usr/local/sample_file.txt

If you prefer a graphical user

interface (GUI), you can use an open source GUI tool named WinSCP.

For more information, go to the

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 适合毕业设计、课程设计作业。这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。 所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值