Rewriting SSH Public Keys Fails After Migration #12552

Closed
opened 2025-11-02 10:13:49 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @inferenceus on GitHub (Feb 27, 2024).

Description

I have migrated my Gitea database, copied all configuration files exactly as they were previously, and renamed all configuration code and system directories to the correct new names wherever they needed to be changed. When I start the Gitea service on the new system, the logs are able to find the new binary, configuration file, and /var/lib/gitea/ directory; however, they state Unable to MkDirAll(/var/lib/<old_name>/.ssh): mkdir /var/lib/<old_name>: permission denied.

There are no references to the old name in the configuration file, and the database and database user have been renamed correctly. It seems Gitea is attempting to create a new directory under the old directory name, despite everything being changed.

Gitea Version

1.21.7

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

https://gist.github.com/inferenceus/2960870b3fbaeba808787832a02eec6c

Screenshots

No response

Git Version

2.43.0

Operating System

Gentoo Linux

How are you running Gitea?

Compiled from source via Gentoo Linux package manager.

Database

PostgreSQL

Originally created by @inferenceus on GitHub (Feb 27, 2024). ### Description I have migrated my Gitea database, copied all configuration files exactly as they were previously, and renamed all configuration code and system directories to the correct new names wherever they needed to be changed. When I start the Gitea service on the new system, the logs are able to find the new binary, configuration file, and `/var/lib/gitea/` directory; however, they state `Unable to MkDirAll(/var/lib/<old_name>/.ssh): mkdir /var/lib/<old_name>: permission denied`. There are no references to the old name in the configuration file, and the database and database user have been renamed correctly. It seems Gitea is attempting to create a new directory under the old directory name, despite everything being changed. ### Gitea Version 1.21.7 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist https://gist.github.com/inferenceus/2960870b3fbaeba808787832a02eec6c ### Screenshots _No response_ ### Git Version 2.43.0 ### Operating System Gentoo Linux ### How are you running Gitea? Compiled from source via Gentoo Linux package manager. ### Database PostgreSQL
GiteaMirror added the type/bug label 2025-11-02 10:13:49 -06:00
Author
Owner

@jolheiser commented on GitHub (Feb 27, 2024):

Can you double-check your app.ini?
2df38af752/models/asymkey/ssh_key_authorized_keys.go (L134-L138)
setting.SSH.RootPath should be sourced from the config.

If it's not explicitly set, it is derived from the current environment
db545b208b/modules/util/path.go (L248-L266)
2df38af752/modules/setting/ssh.go (L114)

@jolheiser commented on GitHub (Feb 27, 2024): Can you double-check your `app.ini`? https://github.com/go-gitea/gitea/blob/2df38af752c13ca02a899d6a53848c68259d3336/models/asymkey/ssh_key_authorized_keys.go#L134-L138 `setting.SSH.RootPath` should be sourced from the config. If it's not explicitly set, it is derived from the current environment https://github.com/go-gitea/gitea/blob/db545b208b4bd3d1961c519da66ee2b4421afa5c/modules/util/path.go#L248-L266 https://github.com/go-gitea/gitea/blob/2df38af752c13ca02a899d6a53848c68259d3336/modules/setting/ssh.go#L114
Author
Owner

@inferenceus commented on GitHub (Feb 27, 2024):

setting.SSH.RootPath should be sourced from the config.

If it's not explicitly set, it is derived from the current environment

Awesome. I didn't know that. It works flawlessly. Thanks for the help.

@inferenceus commented on GitHub (Feb 27, 2024): > `setting.SSH.RootPath` should be sourced from the config. > > If it's not explicitly set, it is derived from the current environment Awesome. I didn't know that. It works flawlessly. Thanks for the help.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#12552