200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > gitlab管理员账号密码重置

gitlab管理员账号密码重置

时间:2019-06-07 15:57:52

相关推荐

gitlab管理员账号密码重置

遇到一台没有管理员账号密码的机器

至于原因嘛,要么是自己忘了、丢了,要么是别人搭建的,反正肯定有理由的嘛

注意:在重置密码前可以试试默认用户名和密码(默认的用户名:admin@密码: 5iveL!fe)

重置密码开始

登录gitlab的服务器

ssh root@IP,然后输入密码登录

2.进入gitlab控制台

gitlab使用rails写的,因为我这台机器使用root启动的gitlab服务,我就没有切换到git用户操作了

如果需要切换到git用户,使用命令: su - git ( - 是连同环境一起切换)

[root@xxx~]# gitlab-rails console productionLoading production environment (Rails 4.2.7.1)

3.通过邮箱admin@查找管理员账号

irb(main):001:0> u = User.where(email: 'admin@').first=> #<User id: 1, email: "admin@", created_at: "-05-30 19:13:41", updated_at: "-03-16 17:26:17", name: "Administrator", admin: true, projects_limit: 10, skype: "", linkedin: "", twitter: "", authentication_token: "ihuTy-LxDUsCSgkmznZ2", theme_id: 2, bio: nil, username: "root", can_create_group: true, can_create_team: false, state: "active", color_scheme_id: 1, password_expires_at: nil, created_by_id: nil, last_credential_check_at: nil, avatar: nil, hide_no_ssh_key: false, website_url: "", notification_email: "admin@", 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, otp_grace_period_started_at: nil, ldap_email: false, external: false, incoming_email_token: "3cbtx58g43ms9qw4pt221ranj", organization: nil, authorized_projects_populated: true>

另外除了通过邮箱的方式找回还可以id=1定位超级管理员

u= User.where(id: 1).first

设置密码

上一步已经将管理员用户对象给了u变量

irb(main):002:0> u.password='new_password'=> "new_password"

保存用户密码

irb(main):003:0> u.save!Enqueued ActionMailer::DeliveryJob (Job ID: 99118288-b58b-4d52-94c1-28979bcb63e8) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/1=> true

这一步save如果报错的话,检查下密码的长度,需要8位以上(网上是这么说的)

退出rails终端

irb(main):004:0> quit

此时管理员账号的密码已经重新设置了,登录即可

作者:maxbin

链接:/p/25afcfd0

来源:简书

简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。