I’m following this doc https://docs.mender.io/hosted/server-integration/preauthorizing-devices , but then again here it uses the device ID to generate the key. In my scenario, the mender client is installed and device isn’t accessed through internet at all, So How do I get the devID.
Is there a way to generate device ID also for preauth
The device’s identity (not to be confused with the Mender generated UUID) can practically be an arbitrary serialized JSON object (with string-type key/value pairs). However, the Mender client typically uses the mac address returned by a script on the device located at /usr/share/mender/identity/mender-device-identity by default.
You can also take a look at the API docs for a more detailed description of the request parameters.
You do not use the “Device ID” which is showed above for pre-authorization. This is just something that is generated on the server the first time the device connects.
The “Device ID” is generated based on a unique pair of a device identity value(s) + a public key. You can read more about this here,
E.g the default is to use the MAC address of the first network interface as a unique identifier and is what you would input in the pre-authorization fields.
I can see how this section of the docs can look confusing as it makes the assumption in the prerequisites that the device already has a network connection. For pre-authorizing a device, all you need is the device’s identity (e.g. {"mac": "00:00:00:00"}) and the public key, the device ID (UUID) will be generated once the device connects for the first time.
For example, a pre-auth curl request may look something like: curl https://hosted.mender.io/api/management/v2/devauth/devices -H "Content-Type: application/json" -H "Authorization: Bearer **JWT token returned by /login**" -d '{"identity_data": {"mac": "00:00:00:00"}, "pubkey": "**PUBLIC PEM BYTES GOES HERE**"}'
openresty/1.13.6.2
curl: (3) Port number ended with '"'
curl: (6) Could not resolve host: pubkey
curl: (3) [globbing] unmatched close brace/bracket in column 573
You need to give the mac of the device you want to pre-authorize. If Mender is installed correctly on the device you can run the script located in /usr/share/mender/identity/mender-device-identity to get the mac address for the correct network interface.
Im still trying, Device gets status: “accepted” from that POST request for Pre-Auth, but for some reason it is getting to pending, I added publickey and key sets to Preauthorized section too,.
Sorry to hear that.
Is the device appearing both as both pending and pre-authorized? If so, can you check if the Device Identity of the two devices are matching?
FYI::
Do you it is because of my Post Auth API to refresh the JWT token (POST, /api/management/v1/useradm/auth/login) , Do u think thats the reason? (But I kept this because JWT token expires in 7 days )
I have added this in my Preauth sec too in server,
Maybe because of this and the preauthorization, it is getting created with twice JWT token? If you think this is the issue, could you tell me how to combine these parameters with the preauth API.
I suspect that the Device Identity passed in the identity_data parameter to the preauth request does not match the id_data in the auth request made from the device.
Can you expand both devices in the UI and compare the Device Identity sections of the pending and pre-authorized devices?
Actually, Now Im not able to check becuase Im having this in my mender status:
r msg=“authorize failed: transient error: authorization request failed: (request_id: ): authentication request rejected server error message: dev auth: unauthorized”
I tried restarting and reinstalling Mender. Still I guess there are “Mac” id of this device existing in the server.
I always run those parameters, and it connects to server in the “pending” state, Now, when this Pre-Auth process Is also been executed I guess two device ID for same mac id is created.
I think so, Isn’t this causing the issue? How do I combine both, because those parameters r giving me the role of adding server.crt and all.