尝试使用 Ruby 脚本从 Amazon EC2(Ubuntu) 实例远程传输或运行命令。我无法从 ssh 和 scp 的 ruby 文档中弄清楚如何通过 .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 主机密钥检查之外,还有其他方法吗?或者在 net-scp 或 net-ssh gem 中是否有用于 ruby 的选项?