Lost the root/admin password? You can reset it using the command-line. Recipe adapted from gitlab issue #308.
# start the console
sudo gitlab-rails console
Then in the ruby interpreter:
# find the user:
# user = User.find_by(email: "[email protected]")
# user = User.find_by(username: "root")
# user = User.find_by(name: "Administrator")
# user = User.find_by(admin: true)
user = User.find_by(username: "root")
# change the password
# or use the ask function from 'highline/import'
user.password = 'secret_pass'
user.password_confirmation = 'secret_pass'
# and save
user.save
# locate application settings
# ApplicationSetting.find_each
appsettings = ApplicationSetting.find_by(signin_enabled: false)
appsettings.signin_enabled = true
appsettings.save
I have found that you can just post the info with your admin token:
- https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/users.md
- http://doc.gitlab.com/ce/api/README.html
import requests
headers = { 'PRIVATE-TOKEN' : 'insert-token-here' }
data = {
'email': email,
'extern_uid': dn,
"provider": "ldapmain",
"name": name,
"username": username,
'password': '1234567890',
"confirm": False,
}
requests.post('https://gitlab.example.com/api/v3/users/', data, headers=headers)
I get the email, dn, name, username from ldap by using python-ldap; I use a filter to only match engineers. The password is required, but you can use a dummy value that matches the security parameters (min 8 characters ...etc)
In case you missed to add confirm=false
when creating users.
gitlab-rails console production
then
for user in User.where(confirmed_at: nil) do
user.confirmed_at = Time.now
user.confirmation_token = nil
user.save!
end
To exit the console, you can hit Ctrl+d (this is the same as EOF, or End Of File)