Verbose Logging

software development with some really amazing hair

T + G I F R

Use Net::SSH With Amazon EC2

· · Posted in Programming
Tagged with

I'm writing up some scripts to automate some EC2 setup, and SSH is required. All the examples for Net::SSH show using just a username and password, which is all good, but the Amazon stuff requires a key file. Here's how to do it:

Net::SSH.start('', 'user', :keys => '/path/to/keypair.pem') { |ssh| … }

According to the docs, the :keys named param takes

an array of file names of private keys to use for publickey and hostbased authentication

but even when I give it a string instead of an array of strings, it works fine.