Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to EC2 using keypair (.pem file) via Fabric

Tags:

python

fabric

Anyone has any Fabric recipe that shows how to connect to EC2 using the pem file?

I tried writing it with this manner: Python Fabric run command returns "binascii.Error: Incorrect padding"

But I'm faced with some encoding issue, when I execute the run() function.

like image 971
Mickey Cheong Avatar asked Feb 21 '11 18:02

Mickey Cheong


People also ask

How do I get an AWS PEM file?

In the left navigation pane, under Network & Security, choose Key Pairs. Choose Create Key Pair and name your key pair your AWS Management Console username (e.g. student01). Choose Create. A PEM file is downloaded in your browser.


1 Answers

To use the pem file I generally add the pem to the ssh agent, then simply refer to the username and host:

ssh-add ~/.ssh/ec2key.pem fab -H ubuntu@ec2-host deploy 

or specify the env information (without the key) like the example you linked to:

env.user = 'ubuntu' env.hosts = [     'ec2-host' ] 

and run as normal:

fab deploy 
like image 138
gak Avatar answered Oct 14 '22 13:10

gak