- Community Home
- >
- Software
- >
- HPE Morpheus Software
- >
- HPE Morpheus Enterprise
- >
- How to Inject SSH Public key during instance creat...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2022 08:13 AM
05-11-2022 08:13 AM
How to Inject SSH Public key during instance creation using Morpheus APIs
Hi,
I’m using this API Documentation to create a Instance https://apidocs.morpheusdata.com/#create-an-instance
I have already created a Key Pair for SSH Public Key.
In the CreateInstance POST method body, under config field there is a provision to add publicKeyId, So i have added the Key pair ID which I have created.
but once the Instance is provisioned, i am unable to do password less login.
the ~/.ssh/authorized_keys file is empty only.
How do I inject or map my ssh public key while creating Instance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2022 08:04 PM
05-15-2022 08:04 PM
Re: How to Inject SSH Public key during instance creation using Morpheus APIs
(post deleted by author)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2022 05:27 AM
05-12-2022 05:27 AM
Re: How to Inject SSH Public key during instance creation using Morpheus APIs
Hello,
The publicKeyId option should tell Morpheus to copy the specified Morpheus AccountKeyPair public key to the authorized_keys file for the username configured on the Host settings for the virtual machine. This could be the cloud-init user as configured in Administration > Provisioning as mentioned by @cbunge.
Have you tried looking in authorized_keys for the cloud-init user?
Hope this helps,
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2022 10:46 AM
05-11-2022 10:46 AM
Re: How to Inject SSH Public key during instance creation using Morpheus APIs
I haven’t passed Create user flag. i’m trying to create VM on ESXi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2022 08:43 AM
05-11-2022 08:43 AM
Re: How to Inject SSH Public key during instance creation using Morpheus APIs
Are you passing the create user flag? I’ll have to test this to confirm things on my end.
Also, which cloud type are you deploying to?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2022 09:57 PM
05-11-2022 09:57 PM
Re: How to Inject SSH Public key during instance creation using Morpheus APIs
I have added Linux user under user settings and updated the SSH Key pair.
When i provision Instance with “createUser”: true, it has created the user and i’m able to do passwordless login to that VM.
This concludes that publicKeyId option is not working because even though i have specified a different publicKeyId than the one which i updated in the linux user settings. it is still not picking it. It is only picking the key pair which is in the Linux user settings.
What is the right usage of using publicKeyId then ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2022 05:30 AM
05-12-2022 05:30 AM
Re: How to Inject SSH Public key during instance creation using Morpheus APIs
@cbunge @ctaylor
I have observed that, Adding the publicKeyId in config section won’t make any difference as it always pick the ssh key pair which is added in the Cloud Init settings for the mentioned user.
My use-case is different.
I want to create a user which is mentioned in the payload under config section and pick the publickeyId which is again mentioned in the payload for the same user. passwordless login should happen for the user.
"config": {
"publicKeyId": 12,
"template": 34,
"resourcePoolId": 34,
"noAgent": false,
"vmwareFolderId": "group-v421"
"createUser": true,
"vmwareUsr": "mark",
"vmwarePwd": "Password!234"
}
As per this, i expect that user mark should be created and passwordless login should happen for the publicKeyId 12
Hope i am clear on my requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2022 06:36 AM
05-12-2022 06:36 AM
Re: How to Inject SSH Public key during instance creation using Morpheus APIs
If your user profile has a password and key assigned, you can set the “createUser”: true flag and it’ll automatically set your user and key under that user’s home dir. No need to specifically call a key id.
If this is a 3rd party user you are trying to add, create a “user group” in Morpheus. Add the user(s) to that group, then in the payload define the usergroup you are adding. Again, any user added this way must have their username/pass/key defined in their Morpheus User profile. At which time, Morpheus will create all of those users and define their keys.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2022 02:55 PM
05-11-2022 02:55 PM
Re: How to Inject SSH Public key during instance creation using Morpheus APIs
The first example you posted isn’t proper create local user payload. That would simply be the “createUser” flag under the config block as shown below. Note this adds the configure (user/pass/cert) under the provisioning user’s profile for Linux creds.
"config": {
"resourcePoolId": 1066,
"publicKeyId": 7,
"hostId": "",
"vmwareFolderId": "group-v1038",
"nestedVirtualization": "off",
"createUser": true
}
Additionally, it appears you are possibly looking at the wrong location for the keys.
You must look under the user deploying the system’s home at $home/.ssh/authorized_keys for the user added (and possibly the cloud-init user home configured under Administration > Provisioning)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2022 11:14 AM
05-11-2022 11:14 AM
Re: How to Inject SSH Public key during instance creation using Morpheus APIs
I have now tried by passing username and pass in config section but it didn’t work for me.
{
"zoneId": 15,
"instance": {
"name": "TEST",
"cloud": "myCloud",
"site": {
"id": 14
},
"instanceType": {
"code": "vmware"
},
"layout": {
"id": 1
},
"plan": {
"id": 2
}
},
"copies": 1,
"layoutSize": 1,
"volumes": [
{
"id": -1,
"rootVolume": true,
"name": "somevol",
"size": 40,
"storageType": 0,
"datastoreId": "auto"
}
],
"networkInterfaces": [
{
"network": {
"id": 1347
},
"networkInterfaceTypeId": 423
}
],
"config": {
"publicKeyId": 5,
"template": 5363,
"resourcePoolId": 787,
"noAgent": false,
"vmwareFolderId": "g42",
"vmwareUsr": "demo",
"vmwarePwd": "demo123"
}
}
Without user and pass
{
"zoneId": 15,
"instance": {
"name": "TEST",
"cloud": "myCloud",
"site": {
"id": 14
},
"instanceType": {
"code": "vmware"
},
"layout": {
"id": 1
},
"plan": {
"id": 2
}
},
"copies": 1,
"layoutSize": 1,
"volumes": [
{
"id": -1,
"rootVolume": true,
"name": "somevol",
"size": 40,
"storageType": 0,
"datastoreId": "auto"
}
],
"networkInterfaces": [
{
"network": {
"id": 1347
},
"networkInterfaceTypeId": 423
}
],
"config": {
"publicKeyId": 5,
"template": 5363,
"resourcePoolId": 787,
"noAgent": false,
"vmwareFolderId": "g42"
}
}
Let me if i am missing anything when you test.