본문 바로가기

기타

GitLab의 root 계정 비밀번호를 초기화하는 방법

반응형

GitLab의 root 계정 비밀번호를 초기화하는 방법

GitLab의 root 계정 비밀번호를 초기화하려면 GitLab 컨테이너 내부에서 gitlab-rails 콘솔을 사용하여 비밀번호를 변경해야 합니다.

 

  • GitLab 컨테이너에 로그 확인
docker-compose logs -f
$ docker-compose logs -f
...
gitlab  |
gitlab  |                 == Seed from /opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/002_admin.rb
gitlab  |                 Administrator account created:
gitlab  |
gitlab  |                 login:    root
gitlab  |                 password: ******
gitlab  |
...
gitlab  | Running handlers:
gitlab  |
gitlab  | Notes:
gitlab  | Default admin account has been configured with following details:
gitlab  | Username: root
gitlab  | Password: You didn't opt-in to print initial root password to STDOUT.
gitlab  | Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.
gitlab  |
gitlab  | NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
gitlab  |
gitlab  | Running handlers complete
gitlab  | Chef Infra Client failed. 441 resources updated in 06 minutes 00 seconds
gitlab  |
gitlab  | Notes:
gitlab  | Default admin account has been configured with following details:
gitlab  | Username: root
gitlab  | Password: You didn't opt-in to print initial root password to STDOUT.
gitlab  | Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.
gitlab  |
gitlab  | NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

초기 비밀번호 확인(initial_root_password)

  • GitLab 컨테이너에 접속
docker-compose exec glab bash
cat /etc/gitlab/initial_root_password
$ docker-compose exec glab bash

# cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: FDA2toARpjTQAx7Imk3jDE5E6a34FofMO/tku9K3K7M=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
728x90

gitlab root 계정 비밀번호 초기화

  • gitlab 컨테이너 진입
docker exec -it gitlab bash
  • GitLab Rails 콘솔 실행
gitlab-rails console -e production
# gitlab-rails console -e production

--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]
 GitLab:       14.4.2 (1ce86e92f81) FOSS
 GitLab Shell: 13.21.1
 PostgreSQL:   12.7
--------------------------------------------------------------------------------
Loading production environment (Rails 6.1.4.1)
irb(main):001:0>
  • Root 계정 비밀번호 변경
user = User.where(id: 1).first
irb(main):004:0> user = User.where(id: 1).first
=> #<User id:1 @root>
user.password='DefaultPassword'
user.password_confirmation='DefaultPassword'
irb(main):005:0> user.password='DefaultPassword'
=> "DefaultPassword"
irb(main):006:0> user.password_confirmation='DefaultPassword'
=> "DefaultPassword"
user.save
irb(main):007:0> user.save
Enqueued ActionMailer::MailDeliveryJob (Job ID: 92e56931-e226-4c20-8459-78d23329499f) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", {:args=>[#<GlobalID:0x00007f4dfbc98c90 @uri=#<URI::GID gid://gitlab/User/1>>]}
=> true
  • 콘솔 종료
exit
  • GitLab 컨테이너 재시작
docker restart gitlab

 

이제 GitLab의 root 계정 비밀번호가 변경되었습니다. 새로운 비밀번호로 로그인할 수 있어야 합니다.


로그인 성공 ^0^!!

 

728x90
반응형