Ni Nipun,

If I am not wrong, in AWS an instance can only be associated to one
key pair, so I'd assume you're just trying to add a key to an existing
user's "authorized_keys" file. You can do that by using the
AuthorizeRSAPublicKeys statement [1]. You can do something like:

// Add the public key to the default user of the instance
computeService.runScriptOnNode("node-id",
   new AuthorizeRSAPublicKeys(ImmutableSet.of("the public key")));

// Add the public key to a specific ssh config directory
computeService.runScriptOnNode("node-id",
   new AuthorizeRSAPublicKeys("/home/foo/.ssh", ImmutableSet.of("the
public key")));


HTH!

I.

[1] 
https://github.com/jclouds/jclouds/blob/master/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/ssh/AuthorizeRSAPublicKeys.java

On 22 June 2014 21:09, Andrew Phillips <[email protected]> wrote:
> Hi Nipun
>
>
>> I need to add a new ssh public key for a existing user in a ec2 instance.
>> I
>> would be grateful if somebody can clarify how to do this with jclouds
>
>
> Just to clarify: do you mean creating a new AWS EC2 key pair? Or do you mean
> changing the private key for an OS user on a running instance of an EC2 AMI?
>
> Regards
>
> ap

Reply via email to