chef-boneyard / knife-oraclecloud

Knife plugin for Oracle Cloud Infrastructure Classic
Apache License 2.0
4 stars 5 forks source link

Unable to associate public key to a provisioned Compute instance #6

Closed rcavenaghi closed 8 years ago

rcavenaghi commented 8 years ago

Creating a compute instance with the following command does create a Compute on Oracle Cloud, but it isn't associated with any public ssh key. So I'm unable to login.

knife oraclecloud server create --image /oracle/public/oel_6.6_apaas_16.1.5_160310 --shape oc3 --hostname test-fmw-prov4 --public-ip pool --identity-file ~/keys/opc_rsa --sshkeys name.username@domain.com/opc_rsa --oraclecloud-username name.username@domain.com --oraclecloud-password pwd --oraclecloud-api-url https://api-z17.compute.us2.oraclecloud.com --oraclecloud-domain domain

Looking at the orchestration json file I can see the following fragment:

"sshkeys": ["Compute-itoracle33422/roberto.cavenaghi@oracle.com/opc_rsa"],

while looking at the orchestration file of an instance provisioned trough webui, the same fragment is (note the '/' character before 'Compute'):

"sshkeys": ["/Compute-itoracle33422/roberto.cavenaghi@oracle.com/opc_rsa"],

This instance is correctly associated with the ssh-key specified in the webui. Can you help me? Thanks.

Roberto

adamleff commented 8 years ago

Roberto - thanks for this report. I was able to replicate this issue, so it appears something has changed in Oracle Cloud's API. It's unfortunate that we provide an SSH key to attach and they don't even provide an error saying they were unable to do so!

Let me dig into this a bit more and see if we can't fix this.

~Adam

adamleff commented 8 years ago

Roberto-

Actually, my replication was faulty as I forgot on Oracle Cloud that the default user for the CentOS images is opc. I re-ran my test with no issue:

knife oraclecloud server create --image /oracle/public/oel_6.6_20GB_x11_RD --shape oc3 --hostname test1 --public-ip pool --ssh-user opc --sshkeys aleff@chef.io/adamleff --identity-file /Users/aleff/.ssh/id_rsa

My instance was successfully started and bootstrapped... and I could log in as the opc user. This was with the SSH key specified without a leading /:

      "objects"=>
       [{"instances"=>
          [{"networking"=>{"eth0"=>{"nat"=>"ippool:/oracle/public/ippool"}},
            "name"=>"Compute-DOMAIN/aleff@chef.io/test1",
            "uri"=>nil,
            "label"=>"test1",
            "shape"=>"oc3",
            "imagelist"=>"/oracle/public/oel_6.6_20GB_x11_RD",
            "sshkeys"=>["Compute-DOMAIN/aleff@chef.io/adamleff"]}]}],
      "status_timestamp"=>nil}],

... so I do not believe this is an issue. I do note that the UI does not show that any SSH keys are associated with my instance, but I can log in without any issue. Can you provide any additional information that might help us figure out what the issue is? From what I can see, everything is operating normally.

Thanks!

rcavenaghi commented 8 years ago

Hi Adam, the problem was the image I used for provisioning: /oracle/public/oel_6.6_apaas_16.1.5_160310. If I use the "/oracle/public/oel_6.6_20GB_x11_RD" image, as you did, everything is fine and the VM is correctly provisioned. Probably there's some ssh issue on the image I was using. Anyway thanks a lot for your help. Bye.

Roberto