500 error when adding public ssh key

The error I get is:

…user/setting/keys.go:181:KeysPost() [E] AddPublicKey: addKey: open /home/git/.ssh/authorized_keys: permission denied

I’ve run into this problem when I tried to clone a repository and it asked me for password to the git user (the one I run gitea with). Trying to fix this I realized that it might be because of the location where my .ssh folder is located. I added the following line to app.ini:

[server]
SSH_ROOT_PATH = /home/git/.ssh

and then tried adding my key, running into the problem from the topic.
I’ve read that the correct permissions are 700 for .ssh folder and 600 for authorized_keys and used chmod to set them - didn’t help. Then I tried setting 777 permissions, which to my surprise didn’t fix the error either, making me think that permission config is not the culprit here.
Here’s how the permissions look now:

git@ubuntu:~$ ls -ld .ssh
drwx------ 2 git git 4096 Apr 27 22:58 .ssh

git@ubuntu:~/.ssh$ ls -ld authorized_keys
-rw------- 1 git git 0 Apr 27 22:49 authorized_keys

Can you help me find out how to fix this? I’d really prefer using ssh and not http, but I can’t because of this error

I got the same issue, for me it was link to the use git UID and GID witch was not matching the container git user. I have modified the docker-compose.

In my case I am using installation with docker with shim strategy, I have also carefully read the note and do some test on that before