【问题标题】:Issue in doing SCP with AWS LightSail pem file使用 AWS LightSail pem 文件执行 SCP 的问题
【发布时间】:2019-01-07 10:54:00
【问题描述】:

我已经在 stackoverflow 中以不同的方式阅读过任何帖子和 cmets,但我仍然在使用 AWS LightSail pem 文件的 SCP 上遇到以下问题。

我尝试将文件从 linux (Centos) 机器复制到 AWS LightSail (Ubuntu)。

请有人告诉我我在这里遗漏了什么以及为什么要求输入密码,如果我输入它会失去连接,AWS Lightsail 不会提供任何密码,除了 pem 文件:

# scp -i LightsailDefaultPrivateKey-ap-south-1.pem -r /home/webadmin/SOMEDOMAIN.com/html/ bitnami@13.232.191.230:/opt/bitnami/apps/newwebsite/htdocs/
The authenticity of host '13.232.191.230 (13.232.191.230)' can't be established.
RSA key fingerprint is 52:cb:2f:95:e1:77:2c:ac:50:66:89:83:15:7f:52:f4.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '13.232.191.230' (RSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'LightsailDefaultPrivateKey-ap-south-1.pem' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: LightsailDefaultPrivateKey-ap-south-1.pem
Enter passphrase for key 'LightsailDefaultPrivateKey-ap-south-1.pem':
Permission denied (publickey).
lost connection

感谢您的指导...

【问题讨论】:

    标签: amazon-web-services scp pem amazon-lightsail


    【解决方案1】:

    以下是解决方案和要遵循的步骤顺序:

    Step1:chmod 400 到您的 LightSailprivatekey,它是 .pem 扩展名/格式。

    Step2:在从任何Linux机器做SCP之前,让我们先做SSH,看看能不能连接到远程服务器,如下: 注意:此步骤仅用于验证,否则可以直接进入Step4。

     [root@previousdomainserver ~]# ssh -i LightsailDefaultPrivateKey-ap-south-1.pem bitnami@13.126.197.129                                  Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-1063-aws x86_64)
           ___ _ _                   _
          | _ |_) |_ _ _  __ _ _ __ (_)
          | _ \ |  _| ' \/ _` | '  \| |
          |___/_|\__|_|_|\__,_|_|_|_|_|
    
      *** Welcome to the Bitnami LAMP 5.6.36-0 ***
      *** Documentation:  https://docs.bitnami.com/aws/infrastructure/lamp/ ***
      ***                 https://docs.bitnami.com/aws/ ***
      *** Bitnami Forums: https://community.bitnami.com/ ***
    Last login: Thu Aug  2 07:54:16 2018 from 78.269.59.279
    bitnami@ip-172-26-15-210:~$
    

    Step3:退出ssh,输入exit如下:

    bitnami@ip-172-26-15-210:~$ exit
    logout
    Connection to 13.126.197.129 closed.
    You have new mail in /var/spool/mail/root
    [root@previousdomainserver~]#
    

    Step4:最后应用 scp 命令,让它像一个魅力一样工作,传输文件很容易,而不是下载到本地机器然后再次上传到目标服务器。您可以在下面看到文件正在复制到目标服务器

    [root@previousdomainserver~]# scp -i LightsailDefaultPrivateKey-ap-south-1.pem -r /home/webadmin/currentdomain.com/html/* bitnami@13.126.197.129:/home/bitnami/downloads/
    about_us-09-08.php                                                                            100% 5749     5.6KB/s   00:00
    about_us-25-04.php                                                                            100% 6291     6.1KB/s   00:00
    about_us.php                                                                                  100% 5768     5.6KB/s   00:00
    activate_account-24-01.php                                                                    100% 1489     1.5KB/s   00:00
    activate_account.php                                                                          100% 1520     1.5KB/s   00:00 
    admin-01-03.php       
    

    另外,为了加快进程,tar/zip 相应的文件夹并应用 scp,这样它会比逐个文件更快地进行

    希望这对其他有需要的人有所帮助...

    【讨论】:

      【解决方案2】:

      您需要将保存您私钥的文件设为只读。

      对于 Linux,这很容易:

      chmod 400 LightsailDefaultPrivateKey-ap-south-1.pem

      数字 400 表示所有者只读,其他任何人(组和其他)都没有权限。

      【讨论】:

      • 嗨 Hanely,有一些进展,但有一个问题如下:** [root@beyondsquare ~]# scp -i LightsailDefaultPrivateKey-ap-south-1.pem -r /home/webadmin/somedomain.com/html bitnami@13.127.209.154:/home/bitnami/apps/newsite/htdocs/ scp: /home/bitnami/apps/newsite/htdocs//html: Permission denied**
      • 此错误意味着您使用了错误的用户名 (root) 或错误的私钥,或者您实际上没有远程系统的权限。我会先让 ssh 工作,然后再让 scp 工作。
      • 感谢 Joh Hanley 的指导和帮助,它就像一个魅力。在主线程中发布作为对此的答案。
      • @UM1979 - 您的回答将帮助其他人。谢谢。
      猜你喜欢
      • 2015-12-13
      • 1970-01-01
      • 2020-07-10
      • 2011-11-21
      • 2018-09-04
      • 2017-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多