【问题标题】:SCP to EC2 not workingSCP到EC2不工作
【发布时间】:2016-07-04 11:21:47
【问题描述】:

所以我有一个 pem 文件:

./test.pem

我有一个文件要移动到我的实例:

path/to/my/file.csv

我想将它移动到我的 ec2 实例:

ec2-user@11.111.111.11

我尝试使用以下命令将文件 scp 到我的 ec2 主目录:

scp -i test.pem path/to/my/file.csv ec2-user@11.111.111.11:~

但它出于某种原因提示我输入密码。知道我在这里有什么问题吗?

-v 的输出:

Executing: program /usr/bin/ssh host 11.111.111.11, user ec2-user, command scp -v -d -t ~
OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to 11.111.111.11 [11.111.111.11] port 22.
debug1: Connection established.
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to 11.111.111.11:22 as 'ec2-user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: xxxx-xxxx-xxxxxxxx 
debug1: Host '11.111.111.11' is known and matches the ECDSA host key.
debug1: Found key in /Users/me/.ssh/known_hosts:19
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,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/me/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /Users/me/.ssh/id_dsa
debug1: Trying private key: /Users/me/.ssh/id_ecdsa
debug1: Trying private key: /Users/me/.ssh/id_edxxxxx
debug1: Next authentication method: password

【问题讨论】:

  • 你能用-v选项发布scp的输出吗?

标签: amazon-web-services amazon-ec2 scp


【解决方案1】:

看起来它没有提供您告诉它的 .pem 文件。那个.pem600 的权限锁定了吗?

可能发生的另一件事:客户端或服务器中的一个或两个拒绝尝试超过设定数量的公钥,因此将-F /dev/null 添加到您的 scp 命令中,这样您的客户端就不会发送任何额外的键(id_dsaid_ecdsa 等)。

【讨论】:

  • 我在 400 和 600 都尝试了 pem,但没有成功。什么ssh命令?我尝试在我的 scp 中使用-F /dev/nulll,但它仍在查找 id_rsa 文件。
  • 对不起,我的意思是“scp”而不是“ssh”,我只是混淆了两者,因为它们有如此相似的论点。您确实将您的公钥添加到远程服务器上的~/.ssh/authorized_keys 文件中,对吧...?
  • 嗯,停止发送这么多私钥的另一种方法是使用ssh-add -d /path/to/public-key.pub(或者,删除代理知道的所有密钥,ssh-add -D)。
  • 我的 pem 密钥包含在 ~/.ssh/authorized_keys 中。使用ssh-add,我应该添加 pem 密钥还是 id_ 文件?
  • .pem 文件您的私钥,这是您应该添加到代理的文件:ssh-add ./test.pem。此私钥的公共部分应该是远程“~/.ssh/authorized_keys”文件中的一行(该行以ssh-rsa AAAA...... 开头)。
猜你喜欢
  • 2018-12-05
  • 1970-01-01
  • 1970-01-01
  • 2018-01-28
  • 2014-05-26
  • 1970-01-01
  • 2021-11-18
  • 2021-07-11
  • 2015-11-10
相关资源
最近更新 更多