passwd
This section shows an example using the passwd command and describes the steps to change or reset the password for an admin account. These steps include using the current password and username but also an ID (aasID). In order to do this, you must first login with current credentials and then communicate with the PAM (Pluggable Authentications Module) that is responsible for users and users’ settings to make changes.
Note: communication with the PAM is based on question-answer format. You send a command and get a response. To change the password, use aasAnswer for both old and new password, username, and aasID (a 30-character alphanumeric string provided after you request a password change, which is not the same as the token used to log in.) There is a timeout. If the interval between commands is too long, you must restart the process.
1. Login into the system.
https://192.168.2.1/api/login?username=admin&password=ganna!23 { "code" : 200, "result" : { "address" : "192.168.2.107", "isipcuser" : false, "isremoteuser" : false, "permission" : "admin", "port" : "41373", "timestamp" : "12:21:19:196", "token" : "801BC4AFBCB465479EB91A1F9D6A0", "user" : "admin" }, "status" : "success" }
2. Execute the command below. You should get an “aasMsg” “Changing password for admin” . It means that you requested the system to change the password. Copy or write down the aasID value as you must use it in the further commands.
https://192.168.2.1/api/command/passwd?data={"username":"admin"}&method=POST { "code" : 200, "result" : { "aasDone" : false, "aasID" : "EF2F537A830EE66DBBAE5A695EC4EC", "aasMsg" : "Changing password for admin.", "aasType" : "info" }, "status" : "success" }
3. In the command below specify the valid aasID along with valid username and current password (aasAnswer). You should get a aasMsg value of Current password in the response.
https://192.168.2.1/api/command/passwd?data={"username":"admin","aasID":"EF2F537A830EE66DBBAE5A695EC4EC","aasAnswer":"ganna!23"}&method=POST { "code" : 200, "result" : { "aasDone" : false, "aasID" : "EF2F537A830EE66DBBAE5A695EC4EC", "aasMsg" : "Current password: ", "aasType" : "question; input hide" }, "status" : "success" }
4. Execute the command below to send the current password. If everything is correct, you will get “New password” as aasMsg.
https://192.168.2.1/api/command/passwd?data={"username":"admin", "aasID": "EF2F537A830EE66DBBAE5A695EC4EC", "aasAnswer":"ganna!23"}&method=POST { "code" : 200, "result" : { "aasDone" : false, "aasID" : "EF2F537A830EE66DBBAE5A695EC4EC", "aasMsg" : "New password: ", "aasType" : "question; input hide" }, "status" : "success" }
5. Execute the command below to enter a new password (AasAnswer). If everything is correct, you will see a message Retype new password in the response.
https://192.168.2.1/api/command/passwd?data={"username":"admin", "aasID": "EF2F537A830EE66DBBAE5A695EC4EC", "aasAnswer":"Admin123"}&method=POST { "code" : 200, "result" : { "aasDone" : false, "aasID" : "EF2F537A830EE66DBBAE5A695EC4EC", "aasMsg" : "Retype new password: ", "aasType" : "question; input hide" }, "status" : "success" }
5. Execute the command again to retype the password. If everything is correct, you will see a Change password success! message.
https://192.168.2.1/api/command/passwd?data={"username":"admin", "aasID": "EF2F537A830EE66DBBAE5A695EC4EC", "aasAnswer":"Admin123"}&method=POST { "code" : 200, "result" : { "aasDone" : true, "aasID" : "EF2F537A830EE66DBBAE5A695EC4EC", "aasMsg" : "Change password success!", "aasType" : "info" }, "status" : "success" }
6. Now your password is changed and you can login using the new password:
https://192.168.2.1/api/login?username=admin&password=Admin123 { "code" : 200, "result" : { "address" : "192.168.2.107", "isipcuser" : false, "isremoteuser" : false, "permission" : "admin", "port" : "41373", "timestamp" : "12:21:19:196", "token" : "801BC4AFBCB465479EB91A1F9D6A0", "user" : "admin" }, "status" : "success" }