Cloning a Gitea repository / Cloner un dépot Gitea

:uk:/:us: English version (French version at the bottom)

My YunoHost server

Hardware: VPS bought online
YunoHost version: 11.0.9.14
I have access to my server : Through SSH | through the webadmin
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : yes
If yes, please explain: password authentication is disabled and ssh is on a custom port

Description of my issue

I have installed Gitea on my Yunohost server. I added my public key (ed25519) to Gitea. I am able to verify that in the file /home/yunohost.app/gitea/.ssh/authorized_keys.
Gitea version is 1.17.2~ynh1
The user gitea is part of the group ssh.app
I think my ssh configuration is correct, I launched the command

yunohost tools regen-conf ssh --force

I restarted the ssh service with the command

sudo yunohost service restart ssh

The file /etc/passwd contains the following line

gitea:x:996:996::/home/yunohost.app/gitea:/bin/bash

I have created a repository in Gitea which I’m trying to clone to my PC with the command

git clone ssh://gitea@domain.tld:<port>/repo/my-project.git

And the result is a ssh error

Cloning into '<my project>'...
Debian GNU/Linux 11
gitea@domain.tld: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I even updated the file ~/.ssh/config to set the IdentityFile to my ssh key (this file seems to not be used by git clone because I have to write the port when cloning…).
And at this point I’m lost :sweat_smile:

I can add that the logs look like

Sep 24 21:51:31 user sshd[12121]: Connection from <my ip> port <port> on <server ip> port <custom port> rdomain ""
Sep 24 21:51:32 user sshd[12121]: Authentication refused: bad ownership or modes for directory /home/yunohost.app/gitea/.ssh
Sep 24 21:51:32 user sshd[12121]: Failed publickey for gitea from <my ip> port <port> ssh2: ED25519 SHA256:+5B4xxxxxxxxxxxxxxxxxxxxxxxxx
Sep 24 21:51:32 user sshd[12121]: Connection closed by authenticating user gitea <my ip> port <port> [preauth]

For your information I read and tried to apply without success the propositions in the following tickets


:fr: Version française

Mon serveur YunoHost

Matériel: VPS acheté en ligne
Version de YunoHost: 11.0.9.14
J’ai accès à mon serveur : En SSH | Par la webadmin
Êtes-vous dans un contexte particulier ou avez-vous effectué des modifications particulières sur votre instance ? : oui
Si oui, expliquer: l’authentification par mot de passe est désactivée et le port ssh a été changé

Description du problème

J’ai installé Gitea sur mon serveur Yunohost. J’ai ajouté ma clé publique (ed25519) dans Gitea. Je peux le vérifier dans le fichier /home/yunohost.app/gitea/.ssh/authorized_keys.
La version Gitea est 1.17.2~ynh1
L’utilisateur gitea fait bien partie du groupe ssh.app
Je pense que ma configuration ssh est correcte, j’ai lancé la commande suivante

yunohost tools regen-conf ssh --force

J’ai redémarré le service ssh avec la commande

sudo yunohost service restart ssh

Le fichier /etc/passwd contient la ligne suivante

gitea:x:996:996::/home/yunohost.app/gitea:/bin/bash

J’ai créé un dépôt dans Gitea que j’essaye de cloner sur mon ordinateur avec la commande

git clone ssh://gitea@domain.tld:<port>/repo/my-project.git

Et le résultat est une erreur ssh

Cloning into '<my project>'...
Debian GNU/Linux 11
gitea@domain.tld: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

J’ai même modifié le fichier ~/.ssh/config pour mettre ma clé ssh à la propriété IdentityFile (ce fichier ne semble pas être utilisé par git clone car il m’est nécessaire de renseigner le port…).
Et maintenant je suis perdu :sweat_smile:

Je peux ajouter les logs sshd :

Sep 24 21:51:31 user sshd[12121]: Connection from <my ip> port <port> on <server ip> port <custom port> rdomain ""
Sep 24 21:51:32 user sshd[12121]: Authentication refused: bad ownership or modes for directory /home/yunohost.app/gitea/.ssh
Sep 24 21:51:32 user sshd[12121]: Failed publickey for gitea from <my ip> port <port> ssh2: ED25519 SHA256:+5B4xxxxxxxxxxxxxxxxxxxxxxxxx
Sep 24 21:51:32 user sshd[12121]: Connection closed by authenticating user gitea <my ip> port <port> [preauth]

Pour information j’ai lu et essayé d’appliquer sans succès les réponses proposées dans les tickets suivants :

:uk:/:us: English version, french version below

I eventually found out what was wrong.
I ran

ssh -p -vvv <port> gitea@domain.tld

and I was able to see that I sent a packet to the server but never had a response.
Then on my server I modified the file /etc/ssh/sshd_config to set the LogLevel to DEBUG, relaunched the ssh service and then relaunched the previous command I got the message

Authentication refused: bad ownership or modes for directory /home/yunohost.app/gitea/.ssh

in the file /var/log/auth.log
It was because group and other had the write permission on the file so the solution was to just to modify the permissions with

chmod 755 /home/yunohost.app/gitea/.ssh

Sorry for thisuseless post, I hope it will help some people with the same problem in the future :wink:

:fr: French version

J’ai finallement trouvé la cause du problème \o/
J’ai lancé la commande

ssh -p -vvv <port> gitea@domain.tld

et j’ai pu voir qu’un paquet était envoyeé au serveur mais n’avait jamais de réponse.
Ensuite j’ai modifié le fichier /etc/ssh/sshd_config sur mon serveur et j’ai positionné LogLevel à DEBUG, relancé le service ssh et ensuite relancé la commande précédente et j’ai obtenu le message

Authentication refused: bad ownership or modes for directory /home/yunohost.app/gitea/.ssh

dans le fichier /var/log/auth.log
C’était parce que group et other avaient la permission write sur le fichier, j’ai donc modifié les permissions avec la commande

chmod 755 /home/yunohost.app/gitea/.ssh

Désolé du post pour rien, j’espère que ça aidera malgré tout des gens dans le futur s’ils ont le même problème que moi :wink:

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.