Recover Lost Cartridge Password in OpenShift Express


I have been working with OpenShift express for quite some time and I create lot of applications and add different cartridge to the application. To access the cartridges using clients you need to  remember the credentials. I developed a small application which was using MongoDB cartridge and I wanted to access the database using mongo shell client on the express instance but I forgot the password. To retrieve the lost password a simple recipe is to log into the express instance using ssh. Get the user information from rhc-user-info command. Once you log into instance just type env command. It will list down all the environment variable and from the list you can recover password. A sample output is shown below.

[example-example.rhcloud.com ~]\> env
OPENSHIFT_NOSQL_DB_USERNAME=admin
SELINUX_ROLE_REQUESTED=
OPENSHIFT_NOSQL_DB_TYPE=mongodb
TERM=xterm
SHELL=/usr/bin/trap-user
OPENSHIFT_LOG_DIR=/var/lib/libra/2b80xxxxxxxxxxxxxxxx4547a74fb42b9/example/logs/
SSH_CLIENT=122.161.141.170 13010 22
OPENSHIFT_NOSQL_DB_URL=mongodb://admin:aCJ5muBZKtjw@127.1.40.1:27017/
OPENSHIFT_TMP_DIR=/tmp/
SELINUX_USE_CURRENT_RANGE=
OPENSHIFT_REPO_DIR=/var/lib/libra/2b80xxxxxxxxxxxxxxxx4547a74fb42b9/example/repo/
OPENSHIFT_HOMEDIR=/var/lib/libra/2b80xxxxxxxxxxxxxxxx4547a74fb42b9/
OPENSHIFT_INTERNAL_PORT=8080
SSH_TTY=/dev/pts/0
USER=2b80xxxxxxxxxxxxxxxx4547a74fb42b9
OPENSHIFT_NOSQL_DB_PASSWORD=aCJ5muBZKtjw
TMOUT=300
OPENSHIFT_NOSQL_DB_MONGODB_20_RESTORE=/usr/libexec/li/cartridges/embedded/mongodb-2.0/info/bin/mongodb_restore.sh
OPENSHIFT_NOSQL_DB_MONGODB_20_DUMP_CLEANUP=/usr/libexec/li/cartridges/embedded/mongodb-2.0/info/bin/mongodb_cleanup.sh
PATH=/usr/libexec/li/cartridges/jbossas-7.0/info/bin/
OPENSHIFT_RUN_DIR=/var/lib/libra/2b80xxxxxxxxxxxxxxxx4547a74fb42b9/example/run/
OPENSHIFT_NOSQL_DB_PORT=27017
OPENSHIFT_INTERNAL_IP=127.1.40.1
PWD=/var/lib/libra/2b80xxxxxxxxxxxxxxxx4547a74fb42b9
OPENSHIFT_NOSQL_DB_MONGODB_20_EMBEDDED_TYPE=mongodb-2.0
JAVA_HOME=/etc/alternatives/java_sdk_1.6.0
OPENSHIFT_APP_DNS=example-example.rhcloud.com
OPENSHIFT_NOSQL_DB_HOST=127.1.40.1
LANG=en_IN
PS1=[example-example.rhcloud.com \W]\>
OPENSHIFT_APP_CTL_SCRIPT=/var/lib/libra/2b80xxxxxxxxxxxxxxxx4547a74fb42b9/example
/example_ctl.sh
JENKINS_URL=http://jenkins-sgulati.rhcloud.com/
SELINUX_LEVEL_REQUESTED=
OPENSHIFT_APP_DIR=/var/lib/libra/2b80xxxxxxxxxxxxxxxx4547a74fb42b9/example/
SHLVL=1
M2_HOME=/etc/alternatives/maven-3.0
HOME=/var/lib/libra/2b80xxxxxxxxxxxxxxxx4547a74fb42b9
OPENSHIFT_APP_TYPE=jbossas-7.0
OPENSHIFT_APP_NAME=example
OPENSHIFT_DATA_DIR=/var/lib/libra/2b80xxxxxxxxxxxxxxxx4547a74fb42b9/example/data/
LOGNAME=2b80xxxxxxxxxxxxxxxx4547a74fb42b9
SSH_CONNECTION=122.161.141.170 13010 10.211.147.239 22
OPENSHIFT_APP_UUID=2b80xxxxxxxxxxxxxxxx4547a74fb42b9
OPENSHIFT_NOSQL_DB_MONGODB_20_DUMP=/usr/libexec/li/cartridges/embedded/mongodb-2.0/info/bin/mongodb_dump.sh
OPENSHIFT_NOSQL_DB_CTL_SCRIPT=/var/lib/libra//2b80xxxxxxxxxxxxxxxx4547a74fb42b9//mongodb-2.0//example_mongodb_ctl.sh
_=/bin/env

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s