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

(一)问题描述:

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

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

 

 

(二)思路分析:

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

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

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

 

 

(三)解决问题:

1、进入GitLab的PostgreSQL数据库

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

(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时,再多次输入错误,又会开启双因子认证。请记清楚密码,否则上述操作再来一遍。

 

posted @ 2019-03-27 13:27  安迪9468  阅读(2955)  评论(0编辑  收藏  举报