scp(安全副本)到ec2实例,无需密码

本文讨论了如何在不输入密码的情况下,通过scp命令安全地将文件复制到Amazon EC2实例。用户在尝试使用scp时遇到密码提示的问题,通过检查和修正ssh密钥文件路径,以及确保使用私钥文件,成功解决了问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文翻译自:scp (secure copy) to ec2 instance without password

I have an EC2 instance running (FreeBSD 9 AMI ami-8cce3fe5), and I can ssh into it using my amazon-created key file without password prompt, no problem. 我有一个正在运行的EC2实例(FreeBSD 9 AMI ami-8cce3fe5),我可以使用我的亚马逊创建的密钥文件将其ssh进入,而无需输入密码提示,没有问题。

However, when I want to copy a file to the instance using scp I am asked to enter a password: 但是,当我想使用scp将文件复制到实例时,要求输入密码:

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

Password:

Any ideas why this is happening/how it can be prevented? 有什么想法为什么会发生/如何预防?


#1楼

参考:https://stackoom.com/question/RW3U/scp-安全副本-到ec-实例-无需密码


#2楼

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

这对你们所有人都非常有帮助


#3楼

scp -i /path/to/your/.pemkey -r /copy/from/path user@server:/copy/to/path

#4楼

My hadoopec2cluster.pem file was the only one in the directory on my local mac, couldn't scp it to aws using scp -i hadoopec2cluster.pem hadoopec2cluster.pem ubuntu@serverip:~ . 我的hadoopec2cluster.pem文件是本地Mac上目录中的唯一文件,无法使用scp -i hadoopec2cluster.pem hadoopec2cluster.pem ubuntu@serverip:~其scp到aws scp -i hadoopec2cluster.pem hadoopec2cluster.pem ubuntu@serverip:~

Copied hadoopec2cluster.pem to hadoopec2cluster_2.pem and then scp -i hadoopec2cluster.pem hadoopec2cluster_2.pem ubuntu@serverip:~ . 将hadoopec2cluster.pem复制到hadoopec2cluster_2.pem,然后将scp -i hadoopec2cluster.pem hadoopec2cluster_2.pem ubuntu@serverip:~复制到hadoopec2cluster_2.pem scp -i hadoopec2cluster.pem hadoopec2cluster_2.pem ubuntu@serverip:~ Voila! 瞧!


#5楼

I was hung up on this because I was specifying my public key file in 我之所以挂在这里,是因为我在中指定了我的公钥文件

scp -i [private key file path]

When I caught that mistake and changed it to the private key path instead, I was all set. 当我发现该错误并将其更改为私钥路径时,一切都准备就绪。


#6楼

lets assume that your pem file and somefile.txt you want to send is in Downloads folder 假设您要发送的pem文件和somefile.txt位于“下载”文件夹中

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

let me know if it doesn't work 让我知道是否无效

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值