Can't login to SSH or push. #216

Closed
opened 2025-11-02 03:14:09 -06:00 by GiteaMirror · 11 comments
Owner

Originally created by @jomp16 on GitHub (Jan 10, 2017).

  • Gitea version (or commit ref): 1.0.0+109-ge5620f07 (commit e5620f07)
  • Git version: 2.11.0
  • Operating system: Arch Linux
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

Application start with the command:

/usr/bin/gitea web --config /var/lib/gitea/custom/conf/app.ini --pid /var/lib/gitea/custom/run/app.pid

I can't login to SSH with gitea user.

ssh -v gitea@hostname gives the following error at the end:

2017/01/10 17:25:54 [...s/setting/setting.go:478 createPIDFile()] [E] Can't create PID folder on mkdir /usr/bin/custom: permission denied

In .ssh/authorized_keys has the lines:

command="/usr/bin/gitea serv key-2 --config='/var/lib/gitea/custom/conf/app.ini'",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa (and public key)

What I can guess it's gitea doesn't add --pid /var/lib/gitea/custom/run/app.pid to ssh file. Adding that small line to authorized_keys gives this error:

2017/01/10 17:33:20 [...tea.io/gitea/main.go:41 main()] [E] Fail to run app with [/usr/bin/gitea serv key-2 --config=/var/lib/gitea/custom/conf/app.ini -pid=/var/lib/gitea/custom/run/app.pid]: flag provided but not defined: -pid

So I don't know what it's going here.

Thanks!

Originally created by @jomp16 on GitHub (Jan 10, 2017). - Gitea version (or commit ref): 1.0.0+109-ge5620f07 (commit e5620f07) - Git version: 2.11.0 - Operating system: Arch Linux - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description Application start with the command: `/usr/bin/gitea web --config /var/lib/gitea/custom/conf/app.ini --pid /var/lib/gitea/custom/run/app.pid` I can't login to SSH with gitea user. `ssh -v gitea@hostname` gives the following error at the end: `2017/01/10 17:25:54 [...s/setting/setting.go:478 createPIDFile()] [E] Can't create PID folder on mkdir /usr/bin/custom: permission denied` In `.ssh/authorized_keys` has the lines: ``` command="/usr/bin/gitea serv key-2 --config='/var/lib/gitea/custom/conf/app.ini'",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa (and public key) ``` What I can guess it's gitea doesn't add --pid /var/lib/gitea/custom/run/app.pid to ssh file. Adding that small line to authorized_keys gives this error: `2017/01/10 17:33:20 [...tea.io/gitea/main.go:41 main()] [E] Fail to run app with [/usr/bin/gitea serv key-2 --config=/var/lib/gitea/custom/conf/app.ini -pid=/var/lib/gitea/custom/run/app.pid]: flag provided but not defined: -pid` So I don't know what it's going here. Thanks!
GiteaMirror added the type/bug label 2025-11-02 03:14:09 -06:00
Author
Owner

@jomp16 commented on GitHub (Jan 10, 2017):

Reverting commit 9f575986d8 I can ssh it, and it show the excepted message:

PTY allocation request failed on channel 0
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.
@jomp16 commented on GitHub (Jan 10, 2017): Reverting commit 9f575986d8021cfab87d1dd664517d4fbd4ea58a I can ssh it, and it show the excepted message: ``` PTY allocation request failed on channel 0 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. ```
Author
Owner

@Bwko commented on GitHub (Jan 10, 2017):

The error message is pretty clear: Can't create PID folder on mkdir /usr/bin/custom: permission denied. Look at the permission denied part. This means that your gitea user isn't allowed to write at the specified --pid folder. Is there any reason why you want to use the --pid flag?

@Bwko commented on GitHub (Jan 10, 2017): The error message is pretty clear: `Can't create PID folder on mkdir /usr/bin/custom: permission denied`. Look at the **permission denied** part. This means that your gitea user isn't allowed to write at the specified `--pid` folder. Is there any reason why you want to use the `--pid` flag?
Author
Owner

@jomp16 commented on GitHub (Jan 10, 2017):

Maybe I wasn't clear enough:

gitea web (flags) works fine, but gitea serv (flags) doesn't work (even with su gitea and running that command in bash).

And under no circumstances any user (except root) can create or edit files in /bin and /usr/bin (that's why it gives an error when trying to create dir /usr/bin/custom).

Seems gitea doesn't follow the $HOME variable or something like that.

So what I propose? Disable pid to gitea serv, or if not possible, or follow $HOME (not sure if possible with ssh), or add a --pid flag like gitea web has.

@jomp16 commented on GitHub (Jan 10, 2017): Maybe I wasn't clear enough: gitea web (flags) works fine, but gitea serv (flags) doesn't work (even with su gitea and running that command in bash). And under no circumstances any user (except root) can create or edit files in /bin and /usr/bin (that's why it gives an error when trying to create dir /usr/bin/custom). Seems gitea doesn't follow the $HOME variable or something like that. So what I propose? Disable pid to gitea serv, or if not possible, or follow $HOME (not sure if possible with ssh), or add a --pid flag like gitea web has.
Author
Owner

@Bwko commented on GitHub (Jan 10, 2017):

@jomp16 Now I get it. I think that Gitea shouldn't create a PID file unless the user specifies a PID path through a --pid flag.

@Bwko commented on GitHub (Jan 10, 2017): @jomp16 Now I get it. I think that Gitea shouldn't create a PID file unless the user specifies a PID path through a --pid flag.
Author
Owner

@Bwko commented on GitHub (Jan 10, 2017):

@jomp16 Could you verify that #637 solves your pid problem?

@Bwko commented on GitHub (Jan 10, 2017): @jomp16 Could you verify that #637 solves your pid problem?
Author
Owner

@jomp16 commented on GitHub (Jan 10, 2017):

Yep, it's working (because I didn't use --pid (I didn't even have that flag on my systemd unit, but I added this to the command on issue because Gitea will create pid file automatically as like someone added that flag)).

And also I think gitea serv don't need a pid argument (not sure if the following affirmation is right, but if two users connect at same time to push something, one of instance may override the pid of the other instance?). Just gitea web is fine (since it's only one instance).

@jomp16 commented on GitHub (Jan 10, 2017): Yep, it's working (because I didn't use `--pid` (I didn't even have that flag on my systemd unit, but I added this to the command on issue because Gitea will create pid file automatically as like someone added that flag)). And also I think `gitea serv` don't need a pid argument (not sure if the following affirmation is right, but if two users connect at same time to push something, one of instance may override the pid of the other instance?). Just `gitea web` is fine (since it's only one instance).
Author
Owner

@lunny commented on GitHub (Jan 11, 2017):

@appleboy

@lunny commented on GitHub (Jan 11, 2017): @appleboy
Author
Owner

@appleboy commented on GitHub (Jan 11, 2017):

Change default behavior to don't create PID file. As @jomp16 mention gitea serv don't need a pid argument.

@appleboy commented on GitHub (Jan 11, 2017): Change default behavior to don't create PID file. As @jomp16 mention `gitea serv` don't need a pid argument.
Author
Owner

@Bwko commented on GitHub (Jan 11, 2017):

@jomp16 & @appleboy You are right, I've updated my PR

@Bwko commented on GitHub (Jan 11, 2017): @jomp16 & @appleboy You are right, I've updated my PR
Author
Owner

@lunny commented on GitHub (Jan 15, 2017):

Is this resolved by #637? @jomp16

@lunny commented on GitHub (Jan 15, 2017): Is this resolved by #637? @jomp16
Author
Owner

@jomp16 commented on GitHub (Jan 15, 2017):

Yep, I was using this PR when they merged it to master branch since "18 hours, 12 minutes, 53 seconds".

I pushed like 5 times, no problems.

I also tested --pid /var/run/gitea/gitea.pid (why inside a subdirectory? Because gitea doesn't have permissions to write in /var/run, and since I don't want to mess with permissions of existing directories, so I made a new directory with user and group gitea.

Thanks for fixing!

@jomp16 commented on GitHub (Jan 15, 2017): Yep, I was using this PR when they merged it to master branch since "18 hours, 12 minutes, 53 seconds". I pushed like 5 times, no problems. I also tested `--pid /var/run/gitea/gitea.pid` (why inside a subdirectory? Because `gitea` doesn't have permissions to write in `/var/run`, and since I don't want to mess with permissions of existing directories, so I made a new directory with user and group `gitea`. Thanks for fixing!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#216