在 Gitea 中更改管理员密码

Change admin password in Gitea

我创建了一个管理员用户,密码包含一个特殊字符。 Gitea 安装成功,但无法登录。我无法获得新密码,因为它说:

Sorry, Register Mail Confirmation has been disabled.

我尝试了命令 gitea admin change-password,但无法识别命令。

your issue 开始,任何 gitea 命令(如 gitea admin change-password --username myusername --password asecurenewpassword)都以:

结尾
gitea: command not found

如果你 installed from binary,你会注意到 $PATH 没有被修改,gitea 是直接从它的安装文件夹调用的。

./gitea web

因此您可以对密码进行同样的操作:

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

注意Robert Ranjan在评论中添加:

/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.

对于当前的 GITEA,有时它将无法工作

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

您还需要指定配置,例如:

cd /path/to/gitea
./gitea admin change-password --username myusername --password asecurenewpassword -c "/etc/gitea/app.ini"

当使用 dockerized gitea 服务时,您必须以 git 用户身份而不是 root:

在容器内执行 gitea admin ... 命令
docker exec -it <container ID> su git bash -c "gitea admin change-password --username <username> --password <password>"

<container ID><username><password> 替换为适当的值。

现在是未来,其他答案将不再有效。我找到了这个答案,因为我遇到了同样的问题。我知道我会再次搞砸,因为这已经是我第二次了,所以你好未来的我!

非docker答案:

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

Docker回答:

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

<container ID><username><password> 替换为适当的值。

Relevant Gitea Documentation

(docker群)

  • docker exec ( 或 ssh 或无论如何你到达 shell
  • 重置的内部命令gitea -c /etc/gitea/app.ini admin admin change-password --username <username> --password <password>
  • 列表的内部命令gitea -c /etc/gitea/app.ini admin user list

对于 NixOS 用户来说,有点复杂:

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

(在 Gitea 版本 1.15.6 上测试)