AMP AMP

How to Reset the Admin Password of Gitlab

How To Reset admin password of gitlab

Resetting procedure

To start the resetting procedure, Login to your gitlab server and execute the following commands in the terminal to gain access for gitlab-rails console

root@linuxhelp:~# gitlab-rails console production
DEPRECATION WARNING: Passing the environment's name as a regular argument is deprecated and will be removed in the next Rails version. Please, use the -e option instead. (called from require at bin/rails:4)
--------------------------------------------------------------------------------
 GitLab:       12.1.0 (295480f4553)
 GitLab Shell: 9.3.0
 PostgreSQL:   10.7
--------------------------------------------------------------------------------
Loading production environment (Rails 5.2.3)
Next use the below command to select the user id whom you want to reset password, in this case its root (admin) user. Here root (admin) user is the very first user so the id must me number 1.
irb(main):001:0> u = User.where(id:1).first
=> #<User id:1 @root>
Next enter the new password for the user using below command.
irb(main):002:0> u.password = 'linux@123'
=> "Netaxis@123"
Confirm the password by entering the following command.
irb(main):010:0> u.password_confirmation = 'linux@123'
=> "Netaxis@123"
Save the password in the console.
irb(main):021:0> u.save!
Enqueued ActionMailer::DeliveryJob (Job ID: 0828d1a8-c7c9-421f-bd32-71b1fce6fbd0) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", #<GlobalID:0x00007ff23a96edb0 @uri=#<URI::GID gid://gitlab/User/1>>
=> true
Now exit from console.
irb(main):027:0> exit

The password has been reset. Now try to login to your gitalb account using the modified password.

snap1

FAQ
Q
What is gitlab?
A
GitLab is a web-based repository manager for teams collaboration. It is used to create, edit new projects and merge finished code into the existing projects.
Q
How to exit the gitlab login console in the terminal?
A
You can exit the gitlab login console by the following the command
> exit
Q
Which command to save the gitlab password?
A
use the following command to save the gitlab password
> u.save!
Q
Why we need to reset the gitlab admin password?
A
Gitlab admin password can be changed easily by using gitlab-rails command. We may have chance of forgetting gitlab admin password, so if we do we actually don&rsquo t need to reinstall gitlab just follow the simple steps to reset your gitlab admin password.
Q
Which command to access the gitlab-rails in terminal?
A
execute the following commands in the terminal to gain access for gitlab-rails console.
# gitlab-rails console production