-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Cannot clone private repo from organization #4941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Could be that same key has added multiple times? |
I don't think so. Would it cause this problem only on private repositories? |
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. |
This maybe resolved? @Governa could you confirm that? |
Not resolved, I have the same problem at v1.7. I can't clone a private repo with a deploy (read-only) rsa key, auth works but clone is denied. Making it public it works. And yes, key is duped but I can't select an already uploaded key for a new repo, GUI makes you recreate the key for every repo you need to clone. |
Absolutely, duped key doesn't work in private repos, but there's no way to have no duplicated keys cause they are needed at every repo you need to clone. |
Could you run |
Have you deleted some public keys? It seems #5684 resolved a key deleted issue. |
Did rebuild the Keys and it doesn't works. Its a bug, not happenning with internal ssh server, change to it and you can clone without problem. |
Ok so that log message is coming from // Check if this deploy key belongs to current repository.
has, err := private.HasDeployKey(key.ID, repo.ID)
if err != nil {
fail("Key access denied", "Failed to access internal api: [key_id: %d, repo_id: %d]", key.ID, repo.ID)
}
if !has {
fail("Key access denied", "Deploy key access denied: [key_id: %d, repo_id: %d]", key.ID, repo.ID)
} So it seems that in the original bug report the problem was that key 6 wasn't associated with repo 58. @jorgefuertes is your error the same? That is it is basically:
If so could you check that you don't have two copies of the same key in the db and which repo key X is associated with. It shouldn't happen that two copies of the same keys end up with different IDs but I guess it's possible. In terms of the difference between the builtin server vs. external they both use this code path in cmd/serv.go - the only difference is the determination of the keyid, so my suspicion is that this key has multiple IDs. |
Certenly, that's the error, an yes, key are duped across different repos, because you can't select a previously uploaded key from another repo. Beside the bug (normal user doesn't need to know about internal or external SSH server, or duped keys), I think I would love to have a common pubkey store, system or organization wide, to choose deploy keys for a project. Thanks everyone. |
This isn't an internal external SSH issue. The problem is the duplicated key id for the same key. It's just that the external SSH and the internal SSH just have slightly different orders for choosing which key id matches a particularly key. There will be repos you can access when using the internal that you can't when using the external and vice versa. Now on master it shouldn't be possible for you to have two deploy key IDs for the same deploy key content so what version are you running? |
I'm running 1.7 right now but tried several versions before. I don't have duped keys into the same repo, I want to make it clear. There are duped keys in a system wide view and that fails using external SSH server. I have no issue with internal SSH server until now. |
I wasn't saying that they're duped within the same repo. It doesn't matter if the same key is used by different repos it should have the always have the same key id. Somehow at least one repo with that key has got it to have a different key id (it may no longer have that wrong key id). Now, according to the current master code that can't happen - so this must have happened in an earlier iteration. IIRC lunny may have committed a bug fix for this. Now, it sounds like the majority of your repos are using the correct key id, so you're not seeing this in the internal SSH server case simply because of different ordering. Ok, so how do fix this and interrogate this further?
Ok, if you're willing to look at the db. Go into your database and look at the
Assure yourself that the fingerprints and names for these deploy keys are the same. Choose one of X or Z as the correct key_id K and wrong key_id W probably the lowest key_id should be K. Now you have two options:
If you can't access your db, or you're unable to translate that SQL to your db. You can look at the |
Thank you very much for this complete explanation, I'll try it. |
@zeripath I think maybe one of your recent PRs has resolved this. |
Hi @lunny yeah my recent PRs should prevent this from happening in future. Unfortunately they won't fix the poor users who have been bitten by these bugs in the past. @jorgefuertes I think my fixes above are still the way to fix your broken state - hopefully that fixed things for you. On master and the 1.7 branch are comprehensive fixes for deployment key and public key constraints which should prevent this from ever happening again. |
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. |
I'm not able to reproduce this issue anymore. Solved |
[x]
):Description
I have two users and an organization:
Cloning an private repository with user_1 works.
Trying to clone an organization's private repository with user_2, fails with the following message:
If I simply make the repository public, user_2 is able to clone it.
The text was updated successfully, but these errors were encountered: