Cant SSH into server if authorized_keys is rewritten #1849

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

Originally created by @angrygoats on GitHub (Jun 3, 2018).

  • Gitea version (or commit ref): 1.3.2
  • Git version: 2.7.4
  • Operating system: Ubuntu server 16.04
  • 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:

Description

I've ran into a little bit of a problem using SSH. I am using OpenSSH on my server. For logging in I have login set to use my SSH keys. This works fine. However, I am unable to communicate with the git server via SSH if this happens.

When I go into the admin panel and rewrite the authorized_keys, I can now push/pull/etc my repos but now I cannot login via the command line. I get an error message saying I authenticated successfully but gitea will not allow me to login. A strange error since gitea shouldn't be managing my SSH, right? I am using the same SSH key for both my gitea user and my gitea account on my test server.

Is there a way around this so I can both login in via SSH to my git server for management purposes (to maintain the account that I use for the git server), and also use SSH to work on my repos via git?

Originally created by @angrygoats on GitHub (Jun 3, 2018). - Gitea version (or commit ref): 1.3.2 - Git version: 2.7.4 - Operating system: Ubuntu server 16.04 - Database (use `[x]`): - [ ] PostgreSQL - [X] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [X] Not relevant - Log gist: ## Description I've ran into a little bit of a problem using SSH. I am using OpenSSH on my server. For logging in I have login set to use my SSH keys. This works fine. However, I am unable to communicate with the git server via SSH if this happens. When I go into the admin panel and rewrite the authorized_keys, I can now push/pull/etc my repos but now I cannot login via the command line. I get an error message saying I authenticated successfully but gitea will not allow me to login. A strange error since gitea shouldn't be managing my SSH, right? I am using the same SSH key for both my gitea user and my gitea account on my test server. Is there a way around this so I can both login in via SSH to my git server for management purposes (to maintain the account that I use for the git server), and also use SSH to work on my repos via git?
Author
Owner

@lunny commented on GitHub (Jun 3, 2018):

You can edit authorized_keys manually to add your public keys back.

@lunny commented on GitHub (Jun 3, 2018): You can edit authorized_keys manually to add your public keys back.
Author
Owner

@angrygoats commented on GitHub (Jun 3, 2018):

@lunny It seems that does not work.

# ssh key
# <gitea key stuff>

Doesn't allow me to use gitea. If I do swap them so the gitea key information is first I am back to getting:

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.
Connection to mygitserver.com closed.

Should I be running the gitea ssh server or something so I can manage the gitea user AND also be able to push code? The documentation didn't really cover this case it seems. I'm fine setting up the gitea ssh server if you can tell me how to do it, especially if it would make it easier to have more users AND allow me to ssh into the server. If needed, I can also change the sshd port to allow room for gitea.

@angrygoats commented on GitHub (Jun 3, 2018): @lunny It seems that does not work. ``` # ssh key # <gitea key stuff> ``` Doesn't allow me to use gitea. If I do swap them so the gitea key information is first I am back to getting: ``` 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. Connection to mygitserver.com closed. ``` Should I be running the gitea ssh server or something so I can manage the gitea user AND also be able to push code? The documentation didn't really cover this case it seems. I'm fine setting up the gitea ssh server if you can tell me how to do it, especially if it would make it easier to have more users _AND_ allow me to ssh into the server. If needed, I can also change the `sshd` port to allow room for gitea.
Author
Owner

@techknowlogick commented on GitHub (Jun 3, 2018):

You should use a different unix user for Gitea from the one you need to SSH into your box with.

@techknowlogick commented on GitHub (Jun 3, 2018): You should use a different unix user for Gitea from the one you need to SSH into your box with.
Author
Owner

@angrygoats commented on GitHub (Jun 3, 2018):

@techknowlogick Will do.

If I want additional users would it just be easier for me to use the built in server?

@angrygoats commented on GitHub (Jun 3, 2018): @techknowlogick Will do. If I want additional users would it just be easier for me to use the built in server?
Author
Owner

@techknowlogick commented on GitHub (Jun 3, 2018):

All Gitea users will share the same ssh account, and Gitea will manage their access to the specific git repos. This is why you received the Gitea does not provide shell access message above because Gitea doesn't want a user to accidentally get shell access.

When you get the clone URL from gitea it'll be something like git@git.example.com:test/test.git, and all users will get the same path, but depending on the SSH key used it'll manage access to the specific repos.

@techknowlogick commented on GitHub (Jun 3, 2018): All Gitea users will share the same ssh account, and Gitea will manage their access to the specific git repos. This is why you received the `Gitea does not provide shell access` message above because Gitea doesn't want a user to accidentally get shell access. When you get the clone URL from gitea it'll be something like `git@git.example.com:test/test.git`, and all users will get the same path, but depending on the SSH key used it'll manage access to the specific repos.
Author
Owner

@angrygoats commented on GitHub (Jun 3, 2018):

Okay great - makes sense, I will go ahead and close this issue.

Thank you.

@angrygoats commented on GitHub (Jun 3, 2018): Okay great - makes sense, I will go ahead and close this issue. Thank you.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1849