TeamCity forgotten admin password - where to look?

Viewed 37933

I need to recover/reset the admin password for JetBrain's TeamCity.

I have full RDP access to the server so no problems there. It's just been 2 months since we used it so now I have forgotten my login - my usual ones don't work.

It is setup without a database at the moment, so was hoping the usernames would just be in a file somewhere, but no luck finding it so far.

19 Answers

Super user direct URL :

http://servername:port/login.html?super=1

Open TeamCity log folder (Example C: drive: C:\TeamCity\logs) : teamcity-server.log, find the key: “Super user authentication”

[2019-03-04 12:14:30,770]   INFO -   jetbrains.buildServer.SERVER - Super user authentication token: `8347518935696887114` (use empty username with the token as the password to access the server)

You could try to reset the installation of TeamCity, by removing TeamCity data directory ($/.BuildServer directory by default)

Try the following:

First stop the TeamCity service (would also stop the build agent if installed). Next open up a console, go to your java directory and run the following command from there:

java.exe -cp server.jar; hsqldb.jar ChangePassword USERNAME PASSWORD "PATH_TO_YOUR_TEAMCITY_INSTALLATION".BuildServer

In case this helps someone else, whoever installed TeamCity on my server placed the build directory under the Administrator's Profile, not in C:\TeamCity.

TeamCity always uses a database - if you haven't explicitly configured one, it uses a HSQLDB database to store data internally.

When using an external database, user information is stored within that database, so it seems pretty likely that the user information in your case will be stored within the HSQLDB system.

You might be able to gain access to the system by futzing around with the database - but I'd suggest taking a backup first.

Second suggestion - drop the support guys at JetBrains an email. Even before my workplace splashed out on a TeamCity Enterprise license, their support was superb - fast, accurate and helpful.

First point is if you logout the login screen has the username 'TCAdmin' already filled in, when it should be 'administrator'. TCAdmin is the full name of (I think) the default version 5 admin user. Changing that to administrator and then using the password I thought it was solved my issue.

For resetting... In case it helps someone else on Windows XP on version 5 of TeamCity, my .BuildServer config info was also under my current logged in user's documents and settings folder. Also I was tripped up by a space in the list of jar files in Sebastien's good answer above.

So I changed to this directory in a command prompt:

 c:\teamcity\webapps\ROOT\WEB-INF\lib 

and then this command line (to set password: Password1) worked for me:

C:\TeamCity\webapps\ROOT\WEB-INF\lib>..\..\..\..\jre\bin\java.exe -cp server.jar;commonapi.jar;commons-codec-1.3.jar;util.jar;hsqldb.jar ChangePassword administrator Password1

Which gave output:

Using TeamCity configuration directory path: C:/Documents and Settings/tamw/.BuildServer 
Password changed successfuly

We are using Teamcity 7 with MS SQL Server as the RDBMS.

To reset your password you can use the following query:

UPDATE users SET password = LOWER(SUBSTRING(sys.fn_sqlvarbasetostr(HASHBYTES('md5','your_new_password')),3,32))
 where username = "your_user_name";

I passed in the same situation and did login with super user, follow steps below:

1 - Get Token in the "teamcity-server.log" in the path "XX:\TeamCity\logs";

2 - Access and login using token at url: "/login.html?super=1";

More about it:

https://confluence.jetbrains.com/display/TCD18/Super+User

Related