본문 바로가기
공부/프로그래밍

[gitlab] root 비밀번호 분실 시 비밀번호 초기화

by demonic_ 2020. 12. 16.
반응형

gitlab 이 설치되어 있는 서버로 접근해야 가능.

 

여기서는 gitlab-ee 로 설치된 것 한해서 가능하다

 

서버에 접속한 후 아래 명령어를 실행한다

sudo gitlab-rails console -e production
--------------------------------------------------------------------------------
 GitLab:       13.2.1 (b55baf593e6) FOSS
 GitLab Shell: 13.3.0
 PostgreSQL:   11.7
--------------------------------------------------------------------------------

 

gitlab은 PostgreSQL을 사용하는 것을 간접적으로(?) 알게된다.

 

root 계정은 첫번째 유저이므로 다음 명령어로 검색해 존재하는지 확인한다

user = User.where(id: 1).first
=> #<User id:1 @root>

비밀번호를 변경한 후 저장한다.

user.password='[변경할 비밀번호]'
user.password_confirmation='[변경할 비밀번호]'
user.save
=> true

 

이제 root 계정으로 접속하면 된다.

 

끝.

 

 

기타:

아래 명령어처럼 하면 에러발생한다

 

sudo gitlab-rails console production
Traceback (most recent call last):
	8: from bin/rails:4:in `<main>'
	7: from bin/rails:4:in `require'
	6: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands.rb:18:in `<top (required)>'
	5: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/command.rb:46:in `invoke'
	4: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/command/base.rb:69:in `perform'
	3: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
	2: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
	1: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands/console/console_command.rb:95:in `perform': wrong number of arguments (given 1, expected 0) (ArgumentError)
	9: from bin/rails:4:in `<main>'
	8: from bin/rails:4:in `require'
	7: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands.rb:18:in `<top (required)>'
	6: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/command.rb:46:in `invoke'
	5: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/command/base.rb:69:in `perform'
	4: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
	3: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
	2: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:20:in `run'
	1: from /opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:34:in `rescue in run'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:506:in `handle_argument_error': ERROR: "rails console" was called with arguments ["production"] (Thor::InvocationError)
Usage: "rails console [options]"

 

입력란에 옵션(-e)을 추가하면 된다

반응형

댓글