1

I am a developer, my current work is writing a script to manage the softlayer VMs. The problems are about change Root Password and binding(remove binding) the SshKey. My questions are:

  1. I have a running softlayer vm, wihch softlayer api can help me to change the vm’s root password.

  2. I have a running softlayer vm which has not bind sshkey before. Does any softlayer api can help me to bind ssh-key with this vm?

  3. Contray to point 2, how can I unbind the sshkey by using softlayer api?

vsminkov
  • 10,912
  • 2
  • 38
  • 50
lippman
  • 33
  • 4

2 Answers2

1

Regarding to your first question, change root password from vm, follow these steps:

Retrieves the password's identifier from the vm

https://$user:$apiKey@api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/$vsiId/getSoftwareComponents?objectMask=mask[passwords]

Method: Get

Replace $user, $apiKey and $vsiId with you own information

You will get a result like this:

hardwareId": null
"id": 345676755
"manufacturerLicenseInstance": "C412F72A-1BB1-4C07-9467-E55729234F8E"
"passwords": [1]
0:  {
"createDate": "2016-06-09T11:10:28-03:00"
"id": 122333
"modifyDate": "2016-09-06T11:19:18-03:00"
"password": "Cochabamba"
"port": null
"softwareId": 11209641
"username": "Ruber"
"software": null
}
}

Then you can update using the following call:

https://$user:$apiKey@api.softlayer.com/rest/v3.1/SoftLayer_Software_Component_Password/$passwordId/editObject

Method: Post

{  
   "parameters":[  
      {  
         "username":"usernameTest",
         "password":"Password*-"
      }
   ]
}

Replace: $user, $apiKey and $passwordId with you own information, in this case the $passwordId is: 122333

Regarding to your second and third question, unfortunately it's not possible to do this through SoftLayer API, it is necessary to do an OS Reload

1
  1. I have a running softlayer vm, wihch softlayer api can help me to change the vm’s root password.

The answer Ruber Cuellar posted will change the password listed in the SoftLayer API, but will not change the password on your system, UNLESS you perform an OS reload. No API method will actually change anything on a running system.

  1. I have a running softlayer vm which has not bind sshkey before. Does any softlayer api can help me to bind ssh-key with this vm?

No. You can add the key manually of course. https://help.ubuntu.com/community/SSH/OpenSSH/Keys

  1. Contray to point 2, how can I unbind the sshkey by using softlayer api? No, but you can remove them manually as well.

The following might also be useful in using SSH keys with the SoftLayer API

http://sldn.softlayer.com/reference/services/SoftLayer_Security_Ssh_Key

http://softlayer-api-python-client.readthedocs.io/en/latest/api/managers/sshkey/

Chris Gallo
  • 191
  • 1
  • 4