Trying to transfer or run commands remotely from an Amazon EC2(Ubuntu) instance with a Ruby script. I am not able to figure out from the ruby doc for ssh and scp how the .pem file can be passed for authentication
# download a file from a remote server
Net::SCP.download!("remote.host.com", "username",
"/remote/path", "/local/path",
:password => password)
I have also tried using command line but the issue here is the host is dynamic and I would have to authenticate 'yes' everytime
`/usr/bin/scp -i keyfile.pem -r [email protected]:/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
Is there any way other than by not disabling SSH host key checking with the command line code. Or is there an option in the net-scp or the net-ssh gem for ruby?
Ruby solution which I did not find in any of their docs
Net::SSH.start( hostname, username, :keys => "/path/to/keyfile.pem" ) do|ssh|
#process
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With