Hi Daniel,

Indeed this the issue is similar, but "overrideLoginUser" works if you are
using the default compute service template builder. In this case I am using
GoogleComputeEngineApi. I do not know how to use "overrideLoginUser" in
this context.

Regards,
Ruben

On Fri, May 22, 2015 at 12:40 PM, Daniel Broudy <[email protected]> wrote:

> I think JCLOUDS-859 is relevant.
>
> https://issues.apache.org/jira/browse/JCLOUDS-859
>
> It sounds like the login user should be 'core'.
>
> On Thu, May 21, 2015 at 6:41 PM, Ruben Rubio Rey <[email protected]>
> wrote:
>
>> Hi Everyone,
>>
>> I am trying to create an instance with GCE and CentOS 7.
>>
>> I am currently using the following code, which adds a public key into
>> root user. The problem is that in CentOS 7 by default disabled root login.
>>
>> GCE creates by default an user in the system, how can I get the username
>> ? If I could set that public key in that username the problem is solved.
>>
>> Thanks in advance!
>>
>> // This is my current code to create GCE instances
>> NewInstance instance = NewInstance.create(NAME, machineType, networkType,
>> uriImage);
>>
>> // generate key
>> JSch jsch = new JSch();
>> KeyPair  kpair = KeyPair.genKeyPair(jsch, KeyPair.RSA);
>> OutputStream publicKey = new ByteArrayOutputStream();
>> OutputStream privateKey = new ByteArrayOutputStream();
>> kpair.writePublicKey(publicKey, null);
>> kpair.writePrivateKey(privateKey);
>>
>> // set new public key
>> instance.metadata().put("sshKeys", String.format("%s:%s %s@localhost",
>> "root", publicKey.toString(), "root"));
>>
>> // create the instance
>> InstanceApi instanceApi = gce.instancesInZone(ZONE);
>> instanceApi.create(instance);
>>
>> Ruben
>>
>
>

Reply via email to