(一)問題描述:
此博客解決如下問題:禁用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時,再多次輸入錯誤,又會開啟雙因子認證。請記清楚密碼,否則上述操作再來一遍。
?