Valkyria Hon
Valkyria Hon

Reputation: 31

How to delete accounts in gerrit (3.0)

I am having trouble with some accounts (I created them using ssh I think so they cannot log in unless development_become_any_account is active.) They get a blank login page now.

I would like to reset these by deleting them, plus recreate them. I am using HTTP Auth if that matters.

I have inspected the user configuration when cloning All-Users and checking out origin/users/self but I really cannot see any difference that may be causing this.

I would really appreciate help with how I go about deleting the bad accounts so that I can start over.

Update

I have noted that the accounts created through ssh never get a "gerrit:" identity. I cannot seem to add a gerrit: identity to accounts - is this possible to do after account creation?

I tried to delete the "accounts/self" ref from All-Users but that ended up making the account unusable but with the username still taken in gerrit, so that wasn't a solution.

Upvotes: 3

Views: 7082

Answers (3)

wizawu
wizawu

Reputation: 2091

  1. Checkout All-Users project from gerrit
git clone ssh://<user>@<gerrit host>:29418/All-Users
  1. Checkout ref refs/meta/external-ids
git fetch origin refs/meta/external-ids:refs/meta/external-ids
git checkout refs/meta/external-ids
  1. Search the account you want to delete, e.g. foobar
grep -r foobar *

398cd83a701a63c77dfc1998f76524561208c879:[externalId "gerrit:foobar"]
398cd83a701a63c77dfc1998f76524561208c879:   email = [email protected]
9b622a00bcd48295d545ba946afdd91df8b0ed61:[externalId "username:foobar"]
  1. Delete those files and commit
git rm 398cd83a701a63c77dfc1998f76524561208c879 9b622a00bcd48295d545ba946afdd91df8b0ed61
git commit -m "Remove account foobar"
git push origin HEAD:refs/meta/external-ids

Upvotes: 3

sporzio
sporzio

Reputation: 1

Tested in Gerrit 3.6.1, you can add the account plugin and delete an account via SSH. The following is the required syntax:

ssh -p 29418 ssh://<user_name>@<host_name> account delete ACCOUNT-ID --yes-really-delete ACCOUNT-NAME

You can retrieve the ACCOUNT-ID by using the admin-console plugin and running the following:

ssh -p 29418 ssh://<user_name>@<host_name> admin-console ls-users|grep <user_to_delete>

Note: This method will still leave the ACCOUNT-ID record of the user in the database, but the user will be set as inactive with their information removed.

Upvotes: 0

Gnustavo
Gnustavo

Reputation: 380

A good way to do it would be to use the Account Endpoints of Gerrit's REST API to inactivate the user. You can do it like this, from the command line:

$ curl -u user:password -X DELETE https://gerrit.example.net/a/accounts/{accound-id}/active

The {account-id} piece is explained here.

Upvotes: 1

Related Questions