我可以通过以下方式进入我的EC2:
ssh -i /Users/User/Downloads/key.pem ubuntu@ec2-myec2.amazonaws.com
我的目录:
/A
/B
/folderToTransfer
我可以使用以下命令rsync进入同一目录:
rsync -avrz -e “ssh -i /Users/User/Downloads/key.pem” /
/Users/User/Documents/Programming/A/B/folderToTransfer /
ubuntu@ec2-myec2.amazonaws.com
新目录:
/A
/B
/folderToTransfer
/ubuntu@ec2-myec2.amazonaws.com
但这失败了(当添加:〜/到最后)
rsync -avrz -e “ssh -i /Users/User/Downloads/key.pem” /
/Users/User/Documents/Programming/A/B/folderToTransfer /
ubuntu@ec2-myec2.amazonaws.com:~/
错误
rsync: Failed to exec ?\#200\#234ssh: No such file or directory (2)
rsync error: error in IPC code (code 14) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/pipe.c(86) [sender=2.6.9]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/io.c(453) [sender=2.6.9]
当使用ssh -i进行rsyncing时,其他人似乎没有同样的问题,我做错了什么?
答案 0 :(得分:2)
rsync -avrz -e “ssh -i /Users/User/Downloads/key.pem” /
^ ^
您在此处未使用ASCII双引号字符"
。您正在使用某种用于排版的开放和关闭引用字符。您的命令失败,因为shell不会将这些字符视为引号; rsync最终尝试执行名为“ssh
的程序。
用ASCII双引号替换字符:
rsync -avrz -e "ssh -i /Users/User/Downloads/key.pem" /
答案 1 :(得分:0)
下面的AWS ec2解决方案(带有键)仅对我有用,并且命令行格式正确
rsync -avz -e "ssh -i /root/xxxxxx.pem" ec2-user@xxxxxx.com:/var/www/ /var/www/copywww/
rsync -avrz -e " ssh -i /root/xxxxxx.pem " ec2-user@xxxxx.com:/var/www/ /var/www/copywww