1. 程式人生 > >gitlab重置用戶密碼

gitlab重置用戶密碼

用戶lms登錄gitlab的密碼忘記了

用戶lms登錄gitlab的密碼忘記了,需要重置密碼。

gitlab重置用戶lms的密碼:

[root@gitlab ~]# gitlab-rails console production  #進入gitlab管理控制臺
Loading production environment (Rails 4.2.4)
irb(main):001:0> user=User.where(name: "lms").first  #查找gitlab用戶lms,一般情況通過名字查找比較方便,如果知道用戶id號可以通過ID號查找,比如默認管理員ID號是1,可以通過這個方法user = User.where(id: 1).first
=> #<User id: 27, email: "[email protected]", encrypted_password: "$2a$10$Nw3rwe2/ftgqcUjsPsvyzeLEQtLprWgaPXxgPWZKMnv...", reset_password_token: "ec60cbd4452aa9d59e1dc45d80a80ab866d5519ff62d0dc325...", reset_password_sent_at: "2016-02-24 06:31:56", remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2016-02-24 06:20:24", last_sign_in_at: "2016-02-24 06:20:24", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", created_at: "2016-02-24 06:18:01", updated_at: "2018-05-15 09:53:53", name: "lmyss", admin: false, projects_limit: 10, skype: "", linkedin: "", twitter: "", authentication_token: "jFX1fkxGDz-tWgyfkd_y", theme_id: 1, bio: nil, failed_attempts: 2, locked_at: nil, username: "lmyss", can_create_group: true, can_create_team: false, state: "active", color_scheme_id: 1, notification_level: 1, password_expires_at: nil, created_by_id: nil, last_credential_check_at: nil, avatar: nil, confirmation_token: "tr_bxK_ZzFqF3yGxRL_t", confirmed_at: "2016-02-24 06:20:24", confirmation_sent_at: "2016-02-24 06:18:01", unconfirmed_email: nil, hide_no_ssh_key: false, website_url: "", notification_email: "[email protected]", hide_no_password: false, password_automatically_set: false, location: nil, encrypted_otp_secret: nil, encrypted_otp_secret_iv: nil, encrypted_otp_secret_salt: nil, otp_required_for_login: false, otp_backup_codes: nil, public_email: "", dashboard: 0, project_view: 0, consumed_timestep: nil, layout: 0, hide_project_limit: false, unlock_token: nil>
irb(main):002:0> user.password=12345678  #針對於查找到的用戶lms重置密碼為12345678
=> 12345678
irb(main):003:0> user.password_confirmation=12345678   #再次確認重置用戶lms密碼為12345678
=> 12345678
irb(main):004:0> user.save!    #保存新密碼
=> true
irb(main):005:0> quit #退出


#查找gitlab用戶lms,一般情況通過名字查找比較方便,如果知道用戶id號可以通過ID號查找,比如默認管理員ID號是1,可以通過這個方法user = User.where(id: 1).first

個人建議用戶名查找優先。

gitlab重置用戶密碼