Verbose Logging

software development with some really amazing hair

22 Jun 09

10:51 AM MDT

Posted in Programming

Use Net::SSH with Amazon EC2

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('my.amazon.hostname.amazonaws.com', '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.

Share/Bookmark

blog comments powered by Disqus