[cs615asa] Question about ssh in python

Dainong Ma dma2 at stevens.edu
Sun Mar 30 23:32:43 EDT 2014


Hello everyone, I have a problem using python to connect ec2-instance.
I write this in python so that I can connect to ec2-instance but I get a
connection refused. I can be sure that I use correct KeyPair and
SecurityGroup. And also I let my program time.sleep(45)
after creating instance.

           command ="ssh -i %s -o StrictHostKeyChecking=no
%s@%s"%(KEYPAIR_LOCATION,
INSTANCE_LOGIN_USR, EC2_HOST)
output: mountvolume (65280, 'ssh: connect to host
ec2-54-208-77-230.compute-1.amazonaws.com port 22: Connection refused\r')

But when I ssh from command line right after that moment:  ssh -i
~/.ssh/ec2backup-keypair.pem -o StrictHostKeyChecking=no
ec2-user at ec2-54-208-77-230.compute-1.amazonaws.com, I can connect it.

Does that mean I can not write ssh command in python like that?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.stevens.edu/mailman/private/cs615asa/attachments/20140330/507de92c/attachment.html>


More information about the cs615asa mailing list