Get 500 when add ssh key #3229

Closed
opened 2025-11-02 05:04:48 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @mengyyy on GitHub (Apr 23, 2019).

  • Gitea version (or commit ref): 1.7.0 and 1.8.0
  • Git version: 2.17.1
  • Operating system: ubuntu 18.04.2 x64
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:
1.7.0
2019/04/23 10:46:07 [I] [SQL] BEGIN TRANSACTION
2019/04/23 10:46:07 [I] [SQL] INSERT INTO `public_key` (`owner_id`,`name`,`fingerprint`,`content`,`mode`,`type`,`login_source_id`,`created_unix`,`updated_unix`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) []interface {}{1, "foo", "SHA256:...", "ssh-rsa AA...", 2, 1, 0, 1555987567, 1555987567}
2019/04/23 10:46:07 [I] [SQL] ROLL BACK
[Macaron] 2019-04-23 10:46:07: Completed POST /user/settings/keys 404 Not Found in 15.947892ms


1.8.0
2019/04/23 10:55:07 [I] [SQL] INSERT INTO `public_key` (`owner_id`,`name`,`fingerprint`,`content`,`mode`,`type`,`login_source_id`,`created_unix`,`updated_unix`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) []interface {}{1, "foo", "SHA256:...", "ssh-rsa AA.....", 2, 1, 0, 1555988107, 1555988107}
2019/04/23 10:55:07 [I] [SQL] ROLL BACK
[Macaron] 2019-04-23 10:55:07: Completed POST /user/settings/keys 500 Internal Server Error in 246.62229ms

Description

I run gitea as root but when I try to add ssh keys i get 500 error.

Screenshots

image

Originally created by @mengyyy on GitHub (Apr 23, 2019). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.7.0 and 1.8.0 - Git version: 2.17.1 - Operating system: ubuntu 18.04.2 x64 - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No - [ ] Not relevant - Log gist: ``` 1.7.0 2019/04/23 10:46:07 [I] [SQL] BEGIN TRANSACTION 2019/04/23 10:46:07 [I] [SQL] INSERT INTO `public_key` (`owner_id`,`name`,`fingerprint`,`content`,`mode`,`type`,`login_source_id`,`created_unix`,`updated_unix`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) []interface {}{1, "foo", "SHA256:...", "ssh-rsa AA...", 2, 1, 0, 1555987567, 1555987567} 2019/04/23 10:46:07 [I] [SQL] ROLL BACK [Macaron] 2019-04-23 10:46:07: Completed POST /user/settings/keys 404 Not Found in 15.947892ms 1.8.0 2019/04/23 10:55:07 [I] [SQL] INSERT INTO `public_key` (`owner_id`,`name`,`fingerprint`,`content`,`mode`,`type`,`login_source_id`,`created_unix`,`updated_unix`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) []interface {}{1, "foo", "SHA256:...", "ssh-rsa AA.....", 2, 1, 0, 1555988107, 1555988107} 2019/04/23 10:55:07 [I] [SQL] ROLL BACK [Macaron] 2019-04-23 10:55:07: Completed POST /user/settings/keys 500 Internal Server Error in 246.62229ms ``` ## Description I run gitea as root but when I try to add ssh keys i get 500 error. ## Screenshots ![image](https://user-images.githubusercontent.com/10589755/56550472-4a830880-65b8-11e9-94b7-499aa76e801c.png) <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the issue/needs-feedback label 2025-11-02 05:04:48 -06:00
Author
Owner

@typeless commented on GitHub (Apr 23, 2019):

From the timestamps of your log, it looks quite easy to reproduce.
But it seems that most people don't encounter this issue.

Where do you get the Gitea binrary? Do you build it from source or some package distributors?

@typeless commented on GitHub (Apr 23, 2019): From the timestamps of your log, it looks quite easy to reproduce. But it seems that most people don't encounter this issue. Where do you get the Gitea binrary? Do you build it from source or some package distributors?
Author
Owner

@mengyyy commented on GitHub (Apr 23, 2019):

From the timestamps of your log, it looks quite easy to reproduce.
But it seems that most people don't encounter this issue.

Where do you get the Gitea binrary? Do you build it from source or some package distributors?

Yes I get the Gitea binrary.
1.7.0 from dl.gitea.io
1.8.0 from github

I do not build it from source.

@mengyyy commented on GitHub (Apr 23, 2019): > From the timestamps of your log, it looks quite easy to reproduce. > But it seems that most people don't encounter this issue. > > Where do you get the Gitea binrary? Do you build it from source or some package distributors? Yes I get the Gitea binrary. 1.7.0 from [dl.gitea.io](https://dl.gitea.io/gitea/1.7.0/gitea-1.7.0-linux-amd64) 1.8.0 from [github](https://github.com/go-gitea/gitea/releases/download/v1.8.0/gitea-1.8.0-linux-amd64) I do not build it from source.
Author
Owner

@lunny commented on GitHub (Apr 25, 2019):

When create SSH key, gitea will save it on your /root/.ssh, maybe you can check the permission of that folder.

@lunny commented on GitHub (Apr 25, 2019): When create SSH key, gitea will save it on your /root/.ssh, maybe you can check the permission of that folder.
Author
Owner

@lafriks commented on GitHub (Apr 25, 2019):

or /home/git/.ssh/...

@lafriks commented on GitHub (Apr 25, 2019): or `/home/git/.ssh/...`
Author
Owner

@mengyyy commented on GitHub (Apr 25, 2019):

Oh…………
before i install gitea I ran
chmod 400 ~/.ssh/authorized_keys && chattr +i ~/.ssh/authorized_keys && chattr +i ~/.ssh

@mengyyy commented on GitHub (Apr 25, 2019): Oh………… before i install gitea I ran `chmod 400 ~/.ssh/authorized_keys && chattr +i ~/.ssh/authorized_keys && chattr +i ~/.ssh`
Author
Owner

@jyling commented on GitHub (Jul 4, 2019):

on what path will it be on the windows ?

@jyling commented on GitHub (Jul 4, 2019): on what path will it be on the windows ?
Author
Owner

@zeripath commented on GitHub (Jul 4, 2019):

If you don't want to write authorized_keys files you can turn them off and switch to use a authorized keys command in the SSH server configuration. See https://docs.gitea.io/en-us/command-line/#keys

@zeripath commented on GitHub (Jul 4, 2019): If you don't want to write authorized_keys files you can turn them off and switch to use a authorized keys command in the SSH server configuration. See https://docs.gitea.io/en-us/command-line/#keys
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3229