我有一个正在运行的EC2实例(FreeBSD 9 AMI AMI -8cce3fe5),我可以使用亚马逊创建的密钥文件ssh到它,没有密码提示,没有问题。

但是,当我想要使用scp将一个文件复制到实例中时,我被要求输入密码:

scp somefile.txt -i mykey.pem root@my.ec2.id.amazonaws.com:/

Password:

你知道为什么会发生这种情况/如何预防吗?


当前回答

scp -i ~/.ssh/key.pem ec2-user@ip:/home/ec2-user/file-to-copy.txt .

文件名不能在pem文件和ec2-user字符串之间——那样不行。这还允许您保留复制文件的名称。

其他回答

将文件从本地服务器复制到远程服务器

sudo scp -i my-pem-file.pem ./source/test.txt ec2-user@1.2.3.4:~/destination/

将文件从远程服务器复制到本地计算机

sudo scp -i my-pem-file.pem ec2-user@1.2.3.4:~/source/of/remote/test.txt ./where/to/put

基本的语法是:-

scp -i my-pem-file.pem username@source:/location/to/file username@destination:/where/to/put

-i是identity_file

我的hadoopec2cluster。Pem文件是我本地mac目录中唯一的一个文件,使用SCP -i hadoopec2cluster无法将其SCP到aws。pem hadoopec2cluster。pem ubuntu@serverip: ~。

hadoopec2cluster复制。Pem到hadoopec2cluster_2。Pem,然后SCP -i hadoopec2cluster。pem hadoopec2cluster_2。pem ubuntu@serverip: ~。瞧!

对于ec2服务器

#移动你的密钥到/tmp或服务器上的右边文件夹

分配权限

Sudo chmod 600 /tmp/dev-sunrobotics-snippetbucketcom.pem

然后连接到服务器或传输

SCP -i /tmp/dev-snippetbucketcom。Pem filestore.tar.gz ubuntu@85.111.5.33.98:/tmp

确保在您的ip安全,您已经允许ip地址连接

我想明白了。我把论点的顺序弄错了。如此:

scp -i mykey.pem somefile.txt root@my.ec2.id.amazonaws.com:/

scp -i /home/barkat/Downloads/LamppServer. xmlpem lampp_x64_12.04.tar.gz

这对你们大家都很有帮助