Bohdan Blyzniuk
Bohdan Blyzniuk

Reputation: 634

Run bash command on aws instance using fog

I am using fog to launch an instance on aws. Here is an example:

server = fog.servers.create(
 :image_id=>'ami-id',
 :flavor_id=>'t2.micro',
 :key_name => 'key',
 )

I have a 'server' object which represents my instance, and now I need to run a bash command or script on my instance. How can I do it via fog?

Upvotes: 1

Views: 77

Answers (1)

Bohdan Blyzniuk
Bohdan Blyzniuk

Reputation: 634

Ok, I found out how to do it, firstly we should add our instance username (on aws default is ubuntu) and path to your key file:

server.username = 'ubuntu'
server.private_key_path = '/path/to/key/Key.pem'

Then, we finally can use ssh method:

server.ssh("your command")

Upvotes: 2

Related Questions