14

I created an admin user with a password, that contains a special character. Installation of Gitea was successful, but I can't login. I can't get new password, because it says:

Sorry, Register Mail Confirmation has been disabled.

I tried command gitea admin change-password, but command is not recognized.

plaidshirt
  • 5,189
  • 19
  • 91
  • 181
  • 1
    For example, can you try running `gitea admin change-password --username myusername --password asecurenewpassword`, replacing `myusername` with your `user name` value. – Hackerman Mar 01 '18 at 19:52
  • I got error: `gitea admin change-password` – plaidshirt Mar 01 '18 at 20:03
  • Are you running that from a terminal? Can you specify which OS are you using? – Hackerman Mar 01 '18 at 20:05
  • Yes, I issued command from Terminal. I use `Ubuntu 17.10 x64`. – plaidshirt Mar 01 '18 at 20:08
  • If that is the full error that you are having then your installation is broken...I strongly recommend you to purge your current install and do a clean one. – Hackerman Mar 01 '18 at 20:14
  • I made it again by this tutorial: https://docs.gitea.io/en-us/install-from-binary/ , but got the same situation. It seems there aren't any package with name `gitea` installed. – plaidshirt Mar 02 '18 at 04:53
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/166083/discussion-between-plaidshirt-and-hackerman). – plaidshirt Mar 02 '18 at 09:21
  • I was reading the documentation and installing gitea is a real PITA...I sugest you to install Gitlab https://about.gitlab.com/installation/#ubuntu – Hackerman Mar 02 '18 at 11:41
  • Maybe yes, but its system requirements are lower than Gitlab's. – plaidshirt Mar 03 '18 at 19:44
  • You had selected the right answer before, what happened? – VonC Dec 30 '19 at 15:16

6 Answers6

18

It's the future now and the other answers will no longer work. I found this answer because I had the same problem. I know I will mess this up again as this is already my second time, so hello future me!

Non-docker answer:

gitea admin user change-password -u <username> -p <password>

Docker answer:

docker exec -it <container ID> su git bash -c "gitea admin user change-password -u <username> -p <password>"

Replace <container ID>, <username> and <password> with the appropriate values.

Relevant Gitea Documentation

Trevor Vance
  • 321
  • 2
  • 11
  • @Magnetron No. That is not correct. Here is the example from the [Gitea Docs](https://docs.gitea.io/en-us/command-line/#admin): `gitea admin user change-password --username myname --password asecurepassword` – Trevor Vance Aug 25 '21 at 17:05
  • 1
    @TrevorVance sorry, you're right, I was using an old version – Magnetron Aug 25 '21 at 17:15
16

From your issue, any gitea command (like gitea admin change-password --username myusername --password asecurenewpassword) ends up with:

gitea: command not found

If you installed from binary, you will note that the $PATH was not modified, and gitea was called directly from its installation folder.

./gitea web

So you can do the same for changing the password:

cd /path/to/gitea
./gitea admin change-password --username myusername --password asecurenewpassword

Note that Robert Ranjan adds in the comments:

/path/to/gitea is gitea's home path, where you find folder custom.
In my case gitea's home is /var/lib/gitea. From this path, you should see file: custom/conf/app.ini which is expected by default.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • `cd /path/to/gitea` is gitea's home path, where you find folder `custom`. In my case gitea's home is `/var/lib/gitea`. From this path, you should see file: `custom/conf/app.ini` which is expected by default. – Robert Ranjan Jun 11 '19 at 15:10
  • 1
    @RobertRanjan OK, I have included your comment in the answer for more visibility. – VonC Jun 11 '19 at 15:14
  • @VonC : I got error message: `models.SetEngine: Failed to connect to database: Unknown database type: 2019/07/17 10:57:10 [I] XORM Log Mode: Console(Info)` – plaidshirt Jul 18 '19 at 06:18
  • @plaidshirt maybe Rendy's answer below can help? If not, it would be best to open a new question. – VonC Jul 18 '19 at 07:34
  • @VonC : I opened new one, because it still persists. – plaidshirt Jul 19 '19 at 08:53
9

For Current GITEA sometime it will not work by

cd /path/to/gitea
./gitea admin change-password --username myusername --password asecurenewpassword

You need to specify the configuration also e.g. :

cd /path/to/gitea
./gitea admin change-password --username myusername --password asecurenewpassword -c "/etc/gitea/app.ini"
Rendy Saputra
  • 161
  • 1
  • 4
4

For NixOS users, it's a bit more complicated:

su
su gitea
nix-shell -p gitea
gitea admin user change-password -c /var/lib/gitea/custom/conf/app.ini -u user-name -p new-pwd

(tested on Gitea version 1.15.6)

luochen1990
  • 3,689
  • 1
  • 22
  • 37
2

When using a dockerized gitea service, you will have to execute the gitea admin ... command inside the container as git user instead of root:

docker exec -it <container ID> su git bash -c "gitea admin change-password --username <username> --password <password>"

Replace <container ID>, <username> and <password> with the appropriate values.

marc
  • 1,207
  • 11
  • 16
2

(docker swarm)

  • docker exec ( or ssh or however you get to shell
  • inner command for reset gitea -c /etc/gitea/app.ini admin admin change-password --username <username> --password <password>
  • inner command for list gitea -c /etc/gitea/app.ini admin user list
Bash Stack
  • 509
  • 3
  • 12