Wednesday, November 30, 2011

How to change all password using curl in CQ / WEM (Till CQ5.4)

=====================================
#!/bin/bash

OLD_PWD=admin
NEW_PWD=admin
CONSOLE_PWD=admin
HOST=localhost
PORT=4502
echo changing crx admin password:
curl --data rep:password=$NEW_PWD --user admin:admin http://$HOST:$PORT/home/users/a/admin

echo change cqse admin password:
curl --data username="admin" --data password_old=$OLD_PWD --data password=$NEW_PWD --data password_check=$NEW_PWD --user admin:admin http://$HOST:$PORT/admin/passwd

echo change replication agent password:
curl --data transportPassword=$NEW_PWD --user admin:$OLD_PWD http://$HOST:$PORT/etc/replication/agents.author/publish/jcr:content

echo change sling crx client password:
echo below script does:
echo 1. find specific pid (needs https://github.com/micha/jsawk)
echo 2. set password property for that pid
FACTORY_PID=com.day.crx.sling.client.impl.CRXSlingClientRepository

PID=`curl -s -u admin:$CONSOLE_PWD "http://$HOST:$PORT/system/console/configMgr/(service.factoryPid=$FACTORY_PID).json" | jsawk -n 'out(this.pid)'`
echo ">> $PID"
curl -s -u admin:$CONSOLE_PWD -dapply=true -dadmin.password=$NEW_PWD -dpropertylist=admin.password http://$HOST/system/console/configMgr/$PID > /dev/null

=====================================


Note: Have not tested it. Please test it before use.

Thanks Alexander Klimetschek from Adobe for this information.

5 comments:

  1. curl --data rep:password=$NEW_PWD --user admin:admin http://$HOST:$PORT/home/users/a/admin

    did not work for me; I instead used:

    curl --data plain=$NEW_PWD --data verify=$NEW_PWD --user admin:admin http://$HOST:$PORT/crx/ui/setpassword.jsp | grep 'Password'

    I also used Perl instead of jsawk for the client repository password change:

    PID=`curl -s -u admin:$CONSOLE_PWD "http://$HOST:$PORT/system/console/configMgr/(service.factoryPid=$FACTORY_PID).json" | perl -ne 'use JSON; $j = decode_json $_; print %{$j->[0]}->{"pid"}'`

    ReplyDelete
    Replies
    1. Thanks Jim for your feed back. It would be handled much better in next release by single CURL command. Will update this post as soon as it is released.

      Delete
  2. Hi I tried to change the replication agent password for cq5.6 and it didnt work with the command posted:

    curl --data transportPassword=$NEW_PWD --user admin:$OLD_PWD http://$HOST:$PORT/etc/replication/agents.author/publish/jcr:content

    regards.

    ReplyDelete
    Replies
    1. Please make sure that it is the default agent you are using. If it is not default agent path could be different.

      Also what version of CQ are you using ?

      Delete
  3. This software has been designed to work in a special way to help reset the password of your system in the simplest way possible.reset windows 10 password

    ReplyDelete