[cs615asa] Some questions.

Jan Schaumann jschauma at stevens.edu
Thu Mar 21 23:02:29 EDT 2013

czhang13 <czhang13 at stevens.edu> wrote:

> If our program does not know the exact key used to create the instance,
> how could we later using ssh with the same key. I mean how could the  
> program
> know what the user's default key is.

Your program does not need to know this.  If the user has not specified
any of the environment variables, then you may assume that running

aws ec2 run-instances --min-count 1 --max-count 1 --image-id ami-whatever

will yield an instance that the user can log in on using

ssh hostname

If the user wishes to use a specific key, she can set the
EC2_BACKUP_FLAGS_AWS environment variable; if she needs to then specify
another flag to ssh(1), she can then set the EC2_BACKUP_FLAGS_SSH
environment variable.

For example, if I would like to create an EC2 instance using non-default
keys and security groups, I'd run

export EC2_BACKUP_FLAGS_AWS="--key-name stevens --security-groups stevens"
ec2-backup -d .

My ~/.ssh/config file is set up so that I do not need to specify any
options to ssh(1) to log in on a host created with those options.  If I
used a different key, say, one called 'ec2key', for which I'd have the
private ssh key stored in ~/.ssh/ec2key but which my ~/.ssh/config does
not use, then I'd run the tool like this:

export EC2_BACKUP_FLAGS_AWS="--key-name ec2key'
export EC2_BACKUP_FLAGS_SSH="-i ~/.ssh/ec2key'
ec2-backup -d .

This way, the 'ec2-backup' tool does not need to know anything at all
about my particular ec2 or ssh setup.  It can just use these environment
variables and assume that will work.


More information about the cs615asa mailing list