Gitea requests password with a correct SSH key

It is probably not a Gitea-specific problem, but maybe you can help me anyway. I got a server that runs no whatever.com with ngingx. And I have a default binary gitea installation running on whatever.com:3000 and nginx proxy from https://git.whatever.com to 3000 port.

The problem is that any request to git asks for a git password even when ssh key is installed and verified:

ssh -T git@git.whatever.com
git@git.sciprog.center's password:

Using

ssh -T altavir@git.whatever.com

with user name (the user from the server itself) from the server works just fine.

Am I right to assume that something went wrong with copying authorized_keys from gitea?

Actually, I found the problem. Git user was not allowed to be accessed via sshd in ssh configuration. I think it makes sense to add a small addition to check it in the installation instructions.

Yoy can try, and if it is ok, you should get:

Hi there, You've successfully authenticated, but Gitea does not provide shell access.
If this is unexpected, please log in with password and setup Gitea under another user.

Documentations below:

SSH issues
If you cannot reach repositories over ssh, but https works fine, consider looking into the following.

First, make sure you can access Gitea via SSH.

ssh git@myremote.example

If the connection is successful, you should receive an error message like the following:

Hi there, You've successfully authenticated, but Gitea does not provide shell access.
If this is unexpected, please log in with password and setup Gitea under another user.

If you do not get the above message but still connect, it means your SSH key is not being managed by Gitea. This means hooks won't run, among other potential problems.

But it shuold’t ask a password.

I have the same problem. And my steps are:
(my gitea user fo service is: “gitea”, not a “git”)

  1. create user in Gitea, for example: alexey111
  2. Create RSA keys on my client with ssh-keygen
  3. Add RSA_Pub part of keys to Gitea interface to alexey111
  4. Try to SSH like this
PS C:\Users\Admin\Desktop\git_test\my-project2> ssh -T gitea@giteahome.local
Hi there, alexey111! You've successfully authenticated with the key named id_ed25519 test, but Gitea does not provide shell access.
If this is unexpected, please log in with password and setup Gitea under another user.

You should check

  1. RSA keys, they also should be in home directory of your git user like: /home/git/.ssh
  2. You should create git user with shell access like:
adduser \
   --shell /bin/bash \

my problems was that i create user without flag --shell /bin/bash, so have no shell at all. And i map user home directory in different folder not in /home/user/, so system can’t find out my rsa keys.

You can also use ssh -vvv to track the problem.

In my case the problem was that I have a security rule about users that are allowed to use ssh and git user was not added to the group.

I’ve done exactly that, but it is not helpful. It says that login with the key failed with error 51. While searching for this error 51, I checked similar issues and had to go to ssh config, there I found the problem. The ssh config is split into several files so it is not that easy to find. Luckily, webmin shows all configuration in the same window.

If a password prompt, that means no public key found on ssh server to match your local private key. The authorized_keys is managed by Gitea and it can be regenerated by click the sync button on admin panel.

The problem is that the key exists, but the user git did not have access rights for ssh. When I added git to ssh allowed users, everything started to work right away. The ssh message log is completely misleading though.

Ah, OK. So you have resolved the problem?

In separate topic i saw this while check my problem.
You need to add the gitea user to the AllowUsers in /etc/ssh/sshd_config
So, it can be like

AllowUsers git

But i don’t know if by default we don’t have allowusers at all, is it mean that averyone have ssh access?

Yes. I left the topic here so people can find the solution.

1 Like