SSH Auth OK but git pull/push not working #7321

Closed
opened 2025-11-02 07:22:54 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @my3rs on GitHub (May 10, 2021).

  • Gitea version (or commit ref): 1.14.1 binary version
  • Git version: 2.29.3
  • Operating system: CentOS 7 64 bit
  • Run gitea by systemd
  • Database (use [x]):
    • MySQL
  • Can you reproduce the bug at https://try.gitea.io:
    • No

Description

ssh auth looks ok

# ssh  git@git.xxx.me
PTY allocation request failed on channel 0
Hi there, seahi! You've successfully authenticated with the key named seahi@DESKTOP-xxx, but Gitea does not provide shell access.
If this is unexpected, please log in with password and setup Gitea under another user.
Connection to git.seahi.me closed.

but when I push/pull, I got the following error:

# git push
Gitea: Internal error
                     fatal: Could not read from remote repository.

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

I already uploaded my ssh public key to my gitea account

Originally created by @my3rs on GitHub (May 10, 2021). - Gitea version (or commit ref): 1.14.1 binary version - Git version: 2.29.3 - Operating system: CentOS 7 64 bit - Run gitea by systemd - Database (use `[x]`): - [x] MySQL - Can you reproduce the bug at https://try.gitea.io: - [x] No ## Description ssh auth looks ok ``` # ssh git@git.xxx.me PTY allocation request failed on channel 0 Hi there, seahi! You've successfully authenticated with the key named seahi@DESKTOP-xxx, but Gitea does not provide shell access. If this is unexpected, please log in with password and setup Gitea under another user. Connection to git.seahi.me closed. ``` but when I push/pull, I got the following error: ``` # git push Gitea: Internal error fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ``` I already uploaded my ssh public key to my gitea account
Author
Owner

@zeripath commented on GitHub (May 10, 2021):

There is very likely to be information in the gitea server logs as to why there is an internal error.

One additional option is to change the authorized_keys command for that key to add --debug to the serv command e.g.:

command="/home/git/gitea/gitea --config='/home/git/gitea/custom/conf/app.ini' serv --debug key-1",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAA...

If that does not help add --debug it to the hooks commands for the repository.

@zeripath commented on GitHub (May 10, 2021): There is very likely to be information in the gitea server logs as to why there is an internal error. One additional option is to change the authorized_keys command for that key to add `--debug` to the serv command e.g.: ``` command="/home/git/gitea/gitea --config='/home/git/gitea/custom/conf/app.ini' serv --debug key-1",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAA... ``` If that does not help add `--debug` it to the hooks commands for the repository.
Author
Owner

@my3rs commented on GitHub (May 10, 2021):

There is no error in logs:

2021/05/10 23:12:31 cmd/web.go:82:runWeb() [I] Starting Gitea on PID: 3152
2021/05/10 23:12:31 ...dules/setting/git.go:101:newGit() [I] Git Version: 2.29.3, Wire Protocol Version 2 Enabled
2021/05/10 23:12:31 cmd/web.go:126:runWeb() [I] Global init
2021/05/10 23:12:31 ...dules/setting/git.go:101:newGit() [I] Git Version: 2.29.3, Wire Protocol Version 2 Enabled
2021/05/10 23:12:31 routers/init.go:134:GlobalInit() [T] AppPath: /www/wwwroot/git/gitea
2021/05/10 23:12:31 routers/init.go:135:GlobalInit() [T] AppWorkPath: /www/wwwroot/git
2021/05/10 23:12:31 routers/init.go:136:GlobalInit() [T] Custom path: /www/wwwroot/git/custom
2021/05/10 23:12:31 routers/init.go:137:GlobalInit() [T] Log path: /www/wwwroot/git/log
2021/05/10 23:12:31 routers/init.go:49:checkRunMode() [I] Run Mode: Prod

## git push started 

2021/05/10 23:12:41 Started GET /api/internal/serv/command/16/seahi/piya?mode=2&verb=git-receive-pack for [::1]:45306
2021/05/10 23:12:41 Completed GET /api/internal/serv/command/16/seahi/piya?mode=2&verb=git-receive-pack 200 OK in 37.790268ms

/www/wwwroot/git/ is the home directory of user git

@my3rs commented on GitHub (May 10, 2021): There is no error in logs: ``` 2021/05/10 23:12:31 cmd/web.go:82:runWeb() [I] Starting Gitea on PID: 3152 2021/05/10 23:12:31 ...dules/setting/git.go:101:newGit() [I] Git Version: 2.29.3, Wire Protocol Version 2 Enabled 2021/05/10 23:12:31 cmd/web.go:126:runWeb() [I] Global init 2021/05/10 23:12:31 ...dules/setting/git.go:101:newGit() [I] Git Version: 2.29.3, Wire Protocol Version 2 Enabled 2021/05/10 23:12:31 routers/init.go:134:GlobalInit() [T] AppPath: /www/wwwroot/git/gitea 2021/05/10 23:12:31 routers/init.go:135:GlobalInit() [T] AppWorkPath: /www/wwwroot/git 2021/05/10 23:12:31 routers/init.go:136:GlobalInit() [T] Custom path: /www/wwwroot/git/custom 2021/05/10 23:12:31 routers/init.go:137:GlobalInit() [T] Log path: /www/wwwroot/git/log 2021/05/10 23:12:31 routers/init.go:49:checkRunMode() [I] Run Mode: Prod ## git push started 2021/05/10 23:12:41 Started GET /api/internal/serv/command/16/seahi/piya?mode=2&verb=git-receive-pack for [::1]:45306 2021/05/10 23:12:41 Completed GET /api/internal/serv/command/16/seahi/piya?mode=2&verb=git-receive-pack 200 OK in 37.790268ms ``` `/www/wwwroot/git/` is the home directory of user git
Author
Owner

@zeripath commented on GitHub (May 10, 2021):

add the --debug to the authorized_keys line and you should get more information.

@zeripath commented on GitHub (May 10, 2021): add the `--debug` to the authorized_keys line and you should get more information.
Author
Owner

@my3rs commented on GitHub (May 11, 2021):

@zeripath Thanks a lot!

After adding --debug to the authorized_keys line, I got the following log:

2021/05/11 10:45:38 ...dules/setting/git.go:101:newGit() [I] Git Version: 2.29.3, Wire Protocol Version 2 Enabled
2021/05/11 10:45:38 cmd/serv.go:129:runServ() [D] SSH_ORIGINAL_COMMAND: git-receive-pack 'seahi/piya.git'

Then I noticed that I compiled a newer git to replace the built-in git, so I just do the following two lns

ln -s /xxx/new-git/git-upload-pack /bin/git-upload-pack
ln -s /xxx/new-git/git-receive-pack /bin/git-receive-pack

Everything is ok now.

@my3rs commented on GitHub (May 11, 2021): @zeripath Thanks a lot! After adding `--debug` to the authorized_keys line, I got the following log: ``` 2021/05/11 10:45:38 ...dules/setting/git.go:101:newGit() [I] Git Version: 2.29.3, Wire Protocol Version 2 Enabled 2021/05/11 10:45:38 cmd/serv.go:129:runServ() [D] SSH_ORIGINAL_COMMAND: git-receive-pack 'seahi/piya.git' ``` Then I noticed that I compiled a newer git to replace the built-in git, so I just do the following two `ln`s ```bash ln -s /xxx/new-git/git-upload-pack /bin/git-upload-pack ln -s /xxx/new-git/git-receive-pack /bin/git-receive-pack ``` Everything is ok now.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7321