关闭gitlab双重认证

root用户登陆gitlab后提示如下,按什么都不管用

iShot2020-12-14 09.16.46

解决方法:直接修改数据库

1.查看 /etc/passwd 文件里边gitlab对应的系统用户

其中 gitlab-psql 就是gitlab系统用户

$ grep gitlab /etc/passwd
gitlab-www:x:995:992::/var/opt/gitlab/nginx:/bin/false
git:x:994:991::/var/opt/gitlab:/bin/sh
gitlab-redis:x:993:990::/var/opt/gitlab/redis:/bin/false
gitlab-psql:x:992:989::/var/opt/gitlab/postgresql:/bin/sh
gitlab-prometheus:x:991:988::/var/opt/gitlab/prometheus:/bin/sh

2.查看gitlab安装时PostgreSQL数据库的配置信息

database一行就是数据库名称

host一行就是pg数据库安装位置

$ cat /var/opt/gitlab/gitlab-rails/etc/database.yml
# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.

production:
  adapter: postgresql
  encoding: unicode
  collation: 
  database: gitlabhq_production
  pool: 10
  username: "gitlab"
  password: 
  host: "/var/opt/gitlab/postgresql"
  port: 5432
  socket: 
  sslmode: 
  sslrootcert: 
  sslca: 
  load_balancing: {"hosts":[]}
  prepared_statements: false
  statements_limit: 1000
  fdw:

3.登陆postgresql数据库,连接到 gitlabhq_production

# 切换用户
su - gitlab-psql

# 连接gitlabhq_production库 
psql -h /var/opt/gitlab/postgresql  -d  gitlabhq_production

pg数据库相关操作

# 查看数据库
\l

# 查看多表
\dt 

# 查看单表,如users表
\d users

4.修改数据库

查看users表中用户的关键信息,取4个字段

SELECT name,username,otp_required_for_login,two_factor_grace_period, require_two_factor_authentication_from_group FROM users;

修改数据库,将二次认证字段的值修改为 f

UPDATE users set require_two_factor_authentication_from_group = 'f' WHERE username = 'root';

5.重新登陆gitlab即可

泡泡吐肥皂o © gitbook.pptfz.top 2021 all right reserved,powered by Gitbook文件修订时间: 秃笔南波湾!!!

results matching ""

    No results matching ""