Change password through JSON RPC

Is there a way to change the root and admin passwords through JSON RPC?

I have found some old threads that state that this isn’t possible, but the credentials for the JRPC access seem very high. If i could simple execute this linux command through JRPC that would work:

echo -e "<yourpassword>\n<yourpassword>" | passwd <user>

but i am unsure how i should format the JRPC message in order to get a piped command to be run.

I have also tried sending this command, which I found is used in the startup scripts given in the SDK to initialize the passwords:

set_password() {
	local user="$1"
	local passwd="$2"

	[ -z "$passwd" ] && passwd="$(mkpasswd admin01)"

	**sed -i -e "s:^$user\:[^\:]*\::$user\:$passwd\::" /etc/shadow**
}

this does seem to change the password, but i think it may add an additional password.

Is there a recommended way to use sed to change the password, or is sending piped command like above possible?

Hello,

In this case, using an ubus call will be the easiest way to set the new password. The call itself should look like so:

{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "call",
    "params": [
        "$sessionid",
        "rpc-sys",
        "password_set",
        {
            "user": "$username",
            "password": "$new_password"
        }
    ]
}

Please remember, that for WebUI, user admin is used.
Hope this helps!

Best regards,

This topic was automatically closed after 15 days. New replies are no longer allowed.