Mender Preauthorisation - bringing the state of the device from preauthorized to accepted

I am trying to preauthorize a device onto the mender dashboard.
I am referring to the below article:

https://docs.mender.io/server-integration/preauthorizing-devices

For this I have done the following:

  1. Used the mender keygen-client to generate a set of public and private key for the device
  2. Used the public key to hit the mender API that puts the particular device into pre-authorisation state.

    The device does come up in the mender dashboard as preauthorized.

What I am trying now is to make the device go from pre-auth state to accepted state for which I have copied the private key (generated from the keygen-client tool) into /data/mender/mender-agent.pem file.
After a restart of the mender client service, insted of making the device go into accepted state a new device request comes on the dashboard (in pending state). So now I have one device entry in preauthorized state and a new entry in pending state.

I had read in the article mentioned above that by default mender considers the MAC ID of the device as the unique identity parameter.
There is a file : mender-device-identity in /etc/mender/identity, it is a script and when I run that it gives the MAC ID of the device as output. I tried modifying the script to output either the serial number, MAC ID or device ID but each time the device was never going into accepted state.

Can someone help me in identifying where I am going wrong with this? I am looking out for a logical flow on how to make the device go to accepted state from pre-authorized state.

If you execute /etc/mender/identity the output should be

sku=<yoursku>
mac=<yourmac>
sn=<yoursn>

and nothing more. The output must correspond to the input of your preauth request. Errors could result that the device is not identified properly. I see in your last image some data is commented out.

Check logs of the client and paste them systemctl status mender or equivalent.