I am trying to automate the process of creating a postgres database from production dump using a python script. I am running this script on an EC2 instance that hosts an RoR app server.
I am able to create the DB using psychopg. But in the same script I want to do the following:
- do a deploy using capistrano from local machine
I came across paramiko - SSHClient in my research. I think it can be used. But I'm not sure how I can SSH from an EC2 instance to my local machine.
I found out my IP(say a.b.c.d) and tried ssh a.b.c.d from the EC2 instance but it says:
ssh: connect to host a.b.c.d port 22: Connection refused
So my question is: - If this method (using paramiko) is correct, how can I set up a ssh connection from EC2 instance to my local machine OR If paramiko cannot achieve this, how can I run the deploy from my script that is on the EC2 instance