个人笔记:个人linuxPC登录aws服务器及复制粘贴文件到服务器

先明确一下取名:

The appropriate user names are as follows:

  • For an Amazon Linux AMI, the user name is ec2-user.

  • For a RHEL AMI, the user name is ec2-user or root.

  • For an Ubuntu AMI, the user name is ubuntu or root.

  • For a Centos AMI, the user name is centos.

  • For a Fedora AMI, the user name is ec2-user.

  • For SUSE, the user name is ec2-user or root.

  • Otherwise, if ec2-user and root don't work, check with the AMI provider.



1. 下载key,下载完成后用ssh -i指令链接服务器.

jinliang@jinliang-ThinkPad-T450s:~/Downloads$ ssh -i 15619demo.pem [email protected]
The authenticity of host 'ec2-54-153-40-255.us-west-1.compute.amazonaws.com (54.153.40.255)' can't be established.
ECDSA key fingerprint is SHA256:1jaAr+oyTWdb/z677fJ9haOXmbXDvrBV8Hl5vlYXZys.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes 
Warning: Permanently added 'ec2-54-153-40-255.us-west-1.compute.amazonaws.com,54.153.40.255' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0664 for '15619demo.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "15619demo.pem": bad permissions
Permission denied (publickey).


提示key的权限 too open,接着输入:

jinliang@jinliang-ThinkPad-T450s:~/Downloads$ ls -l 15619demo.pem
-rw-rw-r-- 1 jinliang jinliang 1692 Jan 19 23:13 15619demo.pem
jinliang@jinliang-ThinkPad-T450s:~/Downloads$ chmod 600 15619demo.pem
jinliang@jinliang-ThinkPad-T450s:~/Downloads$ ssh -i 15619demo.pem [email protected]

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2016.09-release-notes/
5 package(s) needed for security, out of 9 available
Run "sudo yum update" to apply all updates.

此时已经安全连接.接下来复制本地文件到服务器. 我们在另一个新开的terminal进入到key所在目录,

jinliang@jinliang-ThinkPad-T450s:~/Downloads$ scp -i 15619demo.pem QS4.cpp [email protected]:/home/ec2-user
QS4.cpp                                                                              100% 5131     5.0KB/s   00:00 

此时提示已经上传成功, 注意要用 scp -i 指令,后面跟key的目录, 之后是要复制的文件的目录(此时二者都在一个目录).


你可能感兴趣的:(Linux,AWS,云计算)