Cannot clone with built-in SSH server #2609

Closed
opened 2025-11-02 04:41:57 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @lfdmn on GitHub (Dec 4, 2018).

  • Gitea version (or commit ref): 3786369
  • Git version: 1.8.3.1
  • Operating system: CentOS 7 on RaspberryPi 3+
  • 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:
1970/01/01 00:04:50 [I] Log Mode: File(Info)
1970/01/01 00:04:50 [I] XORM Log Mode: File(Info)
1970/01/01 00:04:50 [I] Cache Service Enabled
1970/01/01 00:04:50 [I] Session Service Enabled
1970/01/01 00:04:51 [I] Git Version: 1.8.3.1
1970/01/01 00:04:51 [I] SQLite3 Supported
1970/01/01 00:04:51 [I] Run Mode: Production
1970/01/01 00:04:51 [I] SSH server started on :2222. Cipher list ([aes128-ctr aes192-ctr aes256-ctr aes128-gcm@openssh.com arcfour256 arcfour128]), key exchange algorithms ([diffie-hellman-group1-sha1 diffie-hellman-group14-sha1 ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521 curve25519-sha256@libssh.org]), MACs ([hmac-sha2-256-etm@openssh.com hmac-sha2-256 hmac-sha1 hmac-sha1-96])
1970/01/01 00:04:54 [I] Listen: http://0.0.0.0:3000

Description

Gitea runs fine and HTTP clone works. The daemon is started with systemd and run as a "git" user. I'm not able to clone any repo using SSH.

I have the following config

[server]
SSH_PORT         = 2222
START_SSH_SERVER = true

At the first run with the built-in server, Gitea wouldn't start because it could not create the gogs private key (permission denied error). So I generated it by hand with the same command than in the source code.

From the previous log we can see now the internal SSH server is started.

I have added my user's public SSH key to Gitea's user settings, opened the firewall port 2222/tcp.

If I don't record my public key, I get an SSH authentication error in gitea.log, which is normal and tells my the server is running:

1970/01/01 09:04:16 [...a/modules/ssh/ssh.go:140 func1()] [E] SSH: Error on handshaking: [ssh: no auth passed yet]

Now with the user's certificate added, I don't get any authentication error, meaning the certificate is found, but I also I don't get any messages in the logs and the clone eventually time's out.

In the doubt, I have disabled the firewall and SELinux. It doesn't change a thing.

I get the same problem with public and private repositories. I checked file permissions and group for the repositories are fine, and I'm able to create repositories and add wiki pages

nmap shows gitea is listening to 2222

# nmap -sT -O localhost
...
Not shown: 992 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
443/tcp  open  https
2222/tcp open  EtherNet/IP-1
...

I've also tried starting gitea manually (not from systemd) from command line after switching to git user; same symptoms

I ran out of ideas.

Originally created by @lfdmn on GitHub (Dec 4, 2018). - Gitea version (or commit ref): 3786369 - Git version: 1.8.3.1 - Operating system: CentOS 7 on RaspberryPi 3+ - 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: ``` 1970/01/01 00:04:50 [I] Log Mode: File(Info) 1970/01/01 00:04:50 [I] XORM Log Mode: File(Info) 1970/01/01 00:04:50 [I] Cache Service Enabled 1970/01/01 00:04:50 [I] Session Service Enabled 1970/01/01 00:04:51 [I] Git Version: 1.8.3.1 1970/01/01 00:04:51 [I] SQLite3 Supported 1970/01/01 00:04:51 [I] Run Mode: Production 1970/01/01 00:04:51 [I] SSH server started on :2222. Cipher list ([aes128-ctr aes192-ctr aes256-ctr aes128-gcm@openssh.com arcfour256 arcfour128]), key exchange algorithms ([diffie-hellman-group1-sha1 diffie-hellman-group14-sha1 ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521 curve25519-sha256@libssh.org]), MACs ([hmac-sha2-256-etm@openssh.com hmac-sha2-256 hmac-sha1 hmac-sha1-96]) 1970/01/01 00:04:54 [I] Listen: http://0.0.0.0:3000 ``` ## Description Gitea runs fine and HTTP clone works. The daemon is started with systemd and run as a "git" user. I'm not able to clone any repo using SSH. I have the following config ``` [server] SSH_PORT = 2222 START_SSH_SERVER = true ``` At the first run with the built-in server, Gitea wouldn't start because it could not create the gogs private key (permission denied error). So I generated it by hand with the same command than in the source code. From the previous log we can see now the internal SSH server is started. I have added my user's public SSH key to Gitea's user settings, opened the firewall port 2222/tcp. If I don't record my public key, I get an SSH authentication error in gitea.log, which is normal and tells my the server is running: ``` 1970/01/01 09:04:16 [...a/modules/ssh/ssh.go:140 func1()] [E] SSH: Error on handshaking: [ssh: no auth passed yet] ``` Now with the user's certificate added, I don't get any authentication error, meaning the certificate is found, but I also I don't get any messages in the logs and the clone eventually time's out. In the doubt, I have disabled the firewall and SELinux. It doesn't change a thing. I get the same problem with public and private repositories. I checked file permissions and group for the repositories are fine, and I'm able to create repositories and add wiki pages nmap shows gitea is listening to 2222 ``` # nmap -sT -O localhost ... Not shown: 992 closed ports PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 443/tcp open https 2222/tcp open EtherNet/IP-1 ... ``` I've also tried starting gitea manually (not from systemd) from command line after switching to git user; same symptoms I ran out of ideas.
GiteaMirror added the issue/staleissue/needs-feedback labels 2025-11-02 04:41:57 -06:00
Author
Owner

@fragfutter commented on GitHub (Dec 4, 2018):

if i remember correctly gitea will spawn git binaries for the actual work. So you need to install git package on the gitea server.

@fragfutter commented on GitHub (Dec 4, 2018): if i remember correctly gitea will spawn git binaries for the actual work. So you need to install git package on the gitea server.
Author
Owner

@lafriks commented on GitHub (Dec 4, 2018):

Did you check selinux audit log?

@lafriks commented on GitHub (Dec 4, 2018): Did you check selinux audit log?
Author
Owner

@lfdmn commented on GitHub (Dec 13, 2018):

@fragfutter yes, Git is installed and I can clone / push / pull via HTTP

@lafriks I checked. There's nothing gitea related there.

@lfdmn commented on GitHub (Dec 13, 2018): @fragfutter yes, Git is installed and I can clone / push / pull via HTTP @lafriks I checked. There's nothing gitea related there.
Author
Owner

@stale[bot] commented on GitHub (Feb 11, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Feb 11, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@lunny commented on GitHub (Feb 11, 2019):

Closed now and feel free to reopen it.

@lunny commented on GitHub (Feb 11, 2019): Closed now and feel free to reopen it.
Author
Owner

@ryanburnette commented on GitHub (Apr 18, 2019):

Add an additional line of Port 2222 to your sshd_config

@ryanburnette commented on GitHub (Apr 18, 2019): Add an additional line of `Port 2222` to your `sshd_config`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2609