how to reset or create new non-Crowd user after migrating Stash

Stash 3.7.1

I migrated/moved our production Stash to another machine for test purposes.

After importing the database, untarring the home directory, doing some config changes,

I can't log in. 

I think I shut off the Crowd authentication method by doing:

update cwd_directory set is_active='F' where id=229377;

(and I no longer get the message:

"The remote authentication server is not available. Please try again later."



I've viewed all the atlassian docs about resetting admin password, adding a new dbuser1/admin user

but when I log in, I now get:

    "You do not have permission to access Stash."


The most recent PostgreSQL sql that I have run, following the documents, is the following:

INSERT INTO cwd_user (id,user_name,lower_user_name,is_active,created_date,updated_date,last_name,lower_last_name,display_name,lower_display_name,email_address,lower_email_address,directory_id,credential) VALUES (999999999,'dbuser1','dbuser1','T','2014-01-08 12:12:12','2014-01-08 12:12:12','dbuser1','dbuser1','dbuser1','dbuser1','','',32769,'{PKCS5S2}4PCXluhV1YoY3yGgp77MfHjoFoS7GwNxif4gQLpwIfqLs9n/3seRLlECMu2CWGtm');
# INSERT INTO stash_user (id, name, slug) VALUES (999999999,'dbuser1','dbuser1');
INSERT INTO stash_user (id) VALUES (999999999);
INSERT INTO sta_global_permission (id, perm_id,user_id) VALUES (999999999,7,999999999);

The atlassian-stash.log log file doesn't print anything out during the failed login.

The audit/atlassian-stash-audit.log does, but nothing about why it is failing.


1 answer

I think you are looking for this.

Hi Balazs, I saw that page, but didn't want to try that at this point.


Note to self:[SOLVED]

I have corrections for this link,'s+Administrator+User that I was following.

The table of stash_user only has one column in it, not 3, so the database being used by my Stash 3.7.1 is set up differently than the one in that link.

If one wants to add a new user, dbuser3, with password admin, these are the specific inserts I had to do to get it to work:

INSERT INTO cwd_user (id,user_name,lower_user_name,is_active,created_date,updated_date,last_name,lower_last_name,display_name,lower_display_name,email_address,lower_email_address,directory_id,credential) VALUES (666666666,'dbuser3','dbuser3','T','2014-01-08 12:12:12','2014-01-08 12:12:12','dbuser3','dbuser3','dbuser3','dbuser3','','',32769,'{PKCS5S2}4PCXluhV1YoY3yGgp77MfHjoFoS7GwNxif4gQLpwIfqLs9n/3seRLlECMu2CWGtm');
INSERT INTO stash_user (id) VALUES (88888888);
INSERT INTO sta_normal_user (user_id, name, slug) VALUES (88888888, 'dbuser3', 'dbuser3');
INSERT INTO sta_global_permission (id, perm_id,user_id) VALUES (777777777,7,88888888);

Restartng the Stash server may be necessary to flush the cache.

The values of 88888888 can be any id value that isn't used already, but they all have to be the same amongst all 3 tables.

The id values of 777777777 and 666666666 can be any value that isn't already used, and can be different values.(I don't think they are used in joins between eachother.)

The user_name of cwd_user table and name/slug value of sta_normal_user table, all need to match.


Have you seen that the page you linked to starts with "For Stash versions 2.11+ see Lockout recovery process."? These instructions you mean to correct are for a much older version.

Good point.

( i had read that same sentence,incorrectly, as meaning that these instructions were "for 2.11+".

But that other page suggests putting the server in "recovery mode" fixing something, and then restarting server back out of recovery mode. Maybe that's the proper way to fix the problem. I wanted to find a similar method of manipulating the database, and possibly even adding an additional user.

Next time I build out a Stash test server, i will try that recovery step and see how it goes.

Thank you for your persistence.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,923 views 7 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you