【问题标题】:Unable to copy multiple files via scp无法通过 scp 复制多个文件
【发布时间】:2016-05-23 10:43:09
【问题描述】:

这个连接到我的 aws 服务器的命令运行良好

ssh -i my_pem.pem ubuntu@ec2-xx-xx-xx-xx.eu-west-1.compute.amazonaws.com

但这不是:

$ scp -v -i my_pem.pem file1 file2 ubuntu@ec2-xx-xx-xx-xx.eu-west-1.compute.amazonaws.com:/home/ubuntu/folder1

更新1

$ ssh -v -i 123.pem ubuntu@xx-xx-xx-xx.xx-west-1.compute.amazonaws.com
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 xx-xx-xx-xx.xx-west-1.compute.amazonaws.com [11.22.33.44] port 22.
debug1: Connection established.
debug1: identity file docs/toh_server.pem type -1
debug1: identity file docs/toh_server.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.4
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.4 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 xx:bb:cc:dd:ee:fdsfdsfdsfdsfdsfds
debug1: Host 'xx-xx-xx-xx.xx-west-1.compute.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /home/me123/.ssh/known_hosts:19
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
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: docs/toh_server.pem
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
Authenticated to xx-xx-xx-xx.xx-west-1.compute.amazonaws.com ([11.33.44.55]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_HK.UTF-8
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-48-generic x86_64)

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

 System information disabled due to load higher than 2.0

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

错误:

Executing: program /usr/bin/ssh host ip-xx-xx-xx-xx, user ubuntu, command scp -v -d -t /home/ubuntu/folder1
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 *
ssh: Could not resolve hostname ip-xx-xx-xx-xx: Name or service not known
lost connection

怎么了?

【问题讨论】:

  • -v stsnds 是做什么用的?为什么不使用相同的语法,只是 -i
  • @datelligence,你为什么不打开文档?
  • “无法解析主机名”看起来不像 scp 和更多文件的问题,而是您的网络。你的~/.ssh/config 文件中有什么?尝试在命令行中输入更多-vvv 以查看更多日志。您的主机名在从scpssh 的途中丢失了
  • @Jakuje,好吧,为什么“ssh”有效?
  • @Jakuje,我应该在 ssh/config 文件中有什么?

标签: ssh amazon-ec2 scp


【解决方案1】:

看看区别

debug1: Connecting to xx-xx-xx-xx.xx-west-1.compute.amazonaws.com [11.22.33.44] port 22.

Executing: program /usr/bin/ssh host ip-xx-xx-xx-xx, user ubuntu, command scp -v -d -t /home/ubuntu/folder1
ssh: Could not resolve hostname ip-xx-xx-xx-xx: Name or service not known

您的 scp 正在连接其他地方,由于您混淆了 IP/地址,我不知道这是有意还是真的。

scp 正在解析您的文件,并且可能在您的文件名中发现了一些 : 字符(第一次猜测 @ 是错误的)并将该文件名解析为 host:path?只用其中一个文件试一试,贴出真实文件名。

或者更确切地说使用sftp。它不关心命令行上的语法。只需sftp your host 然后:

cd folder1
put my_file file2

【讨论】:

  • 你的 scp 正在连接其他地方,因为你混淆了 IP/地址 我认为这只是一个真实的 IP 地址,因为在命令中我使用了主机名跨度>
猜你喜欢
  • 1970-01-01
  • 2011-07-06
  • 2014-12-21
  • 1970-01-01
  • 2015-03-17
  • 2014-11-13
  • 2013-05-28
  • 2011-04-08
  • 2023-01-11
相关资源
最近更新 更多