加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

使用Ruby中的SCP / SSH和Amazon EC2实例中的pem文件

发布时间:2020-12-17 03:55:31 所属栏目:百科 来源:网络整理
导读:尝试使用 Ruby脚本从Amazon EC2(Ubuntu)实例远程传输或运行命令. 我无法从ruby doc中了解ssh和scp如何传递.pem文件进行身份验证 # download a file from a remote serverNet::SCP.download!("remote.host.com","username","/remote/path","/local/path",:pas
尝试使用 Ruby脚本从Amazon EC2(Ubuntu)实例远程传输或运行命令.
我无法从ruby doc中了解ssh和scp如何传递.pem文件进行身份验证

# download a file from a remote server
Net::SCP.download!("remote.host.com","username","/remote/path","/local/path",:password => password)

我也试过使用命令行,但这里的问题是主机是动态的,我必须每次都验证’是’

`/usr/bin/scp -i keyfile.pem -r username@some.random.ip:/remote/path /local/path`

The authenticity of host 'some.random.ip (some.random.ip)' can't be established.
ECDSA key fingerprint is some:random:fingerprint.
Are you sure you want to continue connecting (yes/no)? yes

除了不使用命令行代码禁用SSH主机密钥检查之外,还有其他方法吗?或者,对于ruby,net-scp或net-ssh gem中是否有选项?

解决方法

Ruby解决方案,我在他们的任何文档中都找不到

Net::SSH.start( hostname,username,:keys => "/path/to/keyfile.pem" ) do|ssh|
    #process
end

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读