强制禁用gitlab的双因子认证:Two-Factor Authentication

(一)问题描述:html

此博客解决以下问题:禁用gitlab的双因子认证git

禁用前,如图(此时,你在gitlab中什么也干不了)web

 

 

(二)思路分析:sql

百度了不少方法,都不可靠(如不可靠的说明:https://stackoverflow.com/questions/31024771/how-to-disable-the-two-factor-authentication-in-gitlabshell

从这里(https://gitlab.com/gitlab-org/gitlab-ce/issues/1960)找到了灵感:修改gitlab数据库,直接粗暴。数据库

目标是将otp_required_for_login  、 require_two_factor_authentication_from_group 这两个字段,都改成false(数据库中用f表示)gitlab

 

 

(三)解决问题:post

一、进入GitLab的PostgreSQL数据库ui

参考:https://www.cnblogs.com/sfnz/p/7131287.html?utm_source=itdadao&utm_medium=referral3d

(1)登录postgresql数据库

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

cat  /etc/passwd

 

2)根据上面的配置信息登录postgresql数据库

 su  -  gitlab-psql    //登录用户

 

(2)链接到gitlabhq_production库

1)查看gitlab安装时PostgreSQL数据库的配置信息

注意:另起一个shell命令窗口使用cat命令。

cat /var/opt/gitlab/gitlab-rails/etc/database.yml

 

2)链接到gitlabhq_production库

注意:在登录postgresql数据库后,紧接着使用如下命令。

psql  -h  /var/opt/gitlab/postgresql  -d  gitlabhq_production 

 

(3)操做数据库

1)查看数据库

\l

2)查看多表

\dt 

 

3)查看单表,如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;

5)修改数据库

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

 

 

6)退出psql使用\q,接着按下回车就好了。 

 

(4)从新登陆gitlab的web查看,双因子认证没有了,能够正常使用了。

注意:双因子认证是屡次输入错误密码登陆gitlab时触发的,若是之后登陆gitlab时,再屡次输入错误,又会开启双因子认证。请记清楚密码,不然上述操做再来一遍。

相关文章
相关标签/搜索