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: "lms@qq.com", 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: "921560897@qq.com", 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
个人建议用户名查找优先。
原文地址:http://blog.51cto.com/sandshell/2116664