gpt4 book ai didi

linux - 使用 putty 中的 scp 命令将文件夹/文件从本地计算机复制到 AWS ec2 实例时,权限被拒绝公钥

转载 作者:太空宇宙 更新时间:2023-11-04 10:54:47 25 4
gpt4 key购买 nike

我有一个运行 ubuntu 的 EC2 实例,我使用 putty 连接到这个实例。我正在尝试将一些文件上传到此实例,但一次又一次地获得权限被拒绝的公钥错误。以下是我尝试但收到相同错误的命令。

    login as: ubuntu
Authenticating with public key "imported-openssh-key"
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-44-generic x86_64)

* Documentation: https://help.ubuntu.com/

System information as of Wed Mar 25 05:21:29 UTC 2015

System load: 0.0 Processes: 147
Usage of /: 11.8% of 15.61GB Users logged in: 1
Memory usage: 47% IP address for eth0: 172.31.24.22
Swap usage: 0%
ubuntu@ip-172-31-24-22:/var/www/html$ scp -r \xampp\htdocs\bucketsorter\index.php ubuntu@ip-172-31-24-22:home/ubuntu/var
Permission denied (publickey).
lost connection
ubuntu@ip-172-31-24-22:/var/www/html$ scp -r -v \xampp\htdocs\bucketsorter\index.php ubuntu@ip-172-31-24-22:home/ubuntu/var
Executing: program /usr/bin/ssh host ip-172-31-24-22, user ubuntu, command scp -v -r -t home/ubuntu/var
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ip-172-31-24-22 [172.31.24.22] port 22.
debug1: Connection established.
debug1: identity file /home/ubuntu/.ssh/id_rsa type -1
debug1: identity file /home/ubuntu/.ssh/id_rsa-cert type -1
debug1: identity file /home/ubuntu/.ssh/id_dsa type -1
debug1: identity file /home/ubuntu/.ssh/id_dsa-cert type -1
debug1: identity file /home/ubuntu/.ssh/id_ecdsa type -1
debug1: identity file /home/ubuntu/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/ubuntu/.ssh/id_ed25519 type -1
debug1: identity file /home/ubuntu/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA e9:2c:36:dd:be:72:1e:8a:cd:4d:1d:71:be:38:51:20
debug1: Host 'ip-172-31-24-22' is known and matches the ECDSA host key.
debug1: Found key in /home/ubuntu/.ssh/known_hosts:2
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/ubuntu/.ssh/id_rsa
debug1: Trying private key: /home/ubuntu/.ssh/id_dsa
debug1: Trying private key: /home/ubuntu/.ssh/id_ecdsa
debug1: Trying private key: /home/ubuntu/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).
lost connection
ubuntu@ip-172-31-24-22:/var/www/html$ scp -r -v -i \Users\Rohan\Desktop\fall2014 courses\research\bucketsort-aws.pem \xampp\htdocs\bucketsorter\index.php ubuntu@ip-172-31-24-22:home/ubuntu/var
Executing: program /usr/bin/ssh host ip-172-31-24-22, user ubuntu, command scp -v -r -d -t home/ubuntu/var
Warning: Identity file UsersRohanDesktopfall2014 not accessible: No such file or directory.
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ip-172-31-24-22 [172.31.24.22] port 22.
debug1: Connection established.
debug1: identity file /home/ubuntu/.ssh/id_rsa type -1
debug1: identity file /home/ubuntu/.ssh/id_rsa-cert type -1
debug1: identity file /home/ubuntu/.ssh/id_dsa type -1
debug1: identity file /home/ubuntu/.ssh/id_dsa-cert type -1
debug1: identity file /home/ubuntu/.ssh/id_ecdsa type -1
debug1: identity file /home/ubuntu/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/ubuntu/.ssh/id_ed25519 type -1
debug1: identity file /home/ubuntu/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA e9:2c:36:dd:be:72:1e:8a:cd:4d:1d:71:be:38:51:20
debug1: Host 'ip-172-31-24-22' is known and matches the ECDSA host key.
debug1: Found key in /home/ubuntu/.ssh/known_hosts:2
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/ubuntu/.ssh/id_rsa
debug1: Trying private key: /home/ubuntu/.ssh/id_dsa
debug1: Trying private key: /home/ubuntu/.ssh/id_ecdsa
debug1: Trying private key: /home/ubuntu/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).
lost connection
ubuntu@ip-172-31-24-22:/var/www/html$

我也尝试过使用 root 用户。自 6 小时以来,我一直在努力弄清楚,现在真的很沮丧。我是 Linux 的新手。请帮我解决这个问题。提前致谢

最佳答案

在示例终端输出中,您的前两次 scp 尝试甚至从未尝试过验证。远程系统只接受公钥身份验证(不接受密码),而 ssh 没有任何公钥可以用来进行身份验证。

在你的第三次 scp 尝试中,有这个:

$ scp -r -v -i \Users\Rohan\Desktop\fall2014 courses\research\bucketsort-aws.pem \xampp\htdocs\bucketsorter\index.php ubuntu@ip-172-31-24-22:home/ubuntu/var
Executing: [...]
Warning: Identity file UsersRohanDesktopfall2014 not accessible: No such file or directory.

您告诉它使用不带引号的 key 文件“\Users\Rohan\Desktop\fall2014 courses\research\bucketsort-aws.pem”。 Scp 最终寻找名为“UsersRohanDesktopfall2014”的 key 文件。它找不到此 key ,因此无法再次进行身份验证。

首先,您的 key 文件的名称包含一个空格,因此它必须用引号括起来才能被视为单个命令行参数。其次,看起来命令行上的反斜杠被破坏了,所以请尝试改用正斜杠:

$ scp -r -v -i "/Users/.../fall2014 courses/research/bucketsort-aws.pem" /xampp/.../index.php ubuntu@ip-172-31-24-22:home/ubuntu/var

这是在 Windows 上?如果 scp 仍然提示找不到 key 文件,请添加驱动器说明符:

$ scp -r -v -i "C:/Users/.../fall2014 courses/research/bucketsort-aws.pem" /xampp/.../index.php ubuntu@ip-172-31-24-22:home/ubuntu/var

关于linux - 使用 putty 中的 scp 命令将文件夹/文件从本地计算机复制到 AWS ec2 实例时,权限被拒绝公钥,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29249562/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com