Page MenuHomePhabricator

Gitiles should add username in git clone links, triggers "Permission denied (publickey)" error
Closed, DuplicatePublic

Description

On https://gerrit.wikimedia.org/r/plugins/gitiles/operations/mediawiki-config/ for example, the url it gives for cloning the repo is ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config. However, that doesn't work and instead gives a permission denied error.

$ git clone ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config
Cloning into 'mediawiki-config'...
Permission denied (publickey).
fatal: Could not read from remote repository.

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

Steeps to reproduce:

Excepted change :

  • The link in the command should contain the username of the logged-in user, like git clone ssh://framawiki@gerrit.wikimedia.org:29418/labs/tools/cdnjs-index. This command works.

Event Timeline

Aklapper renamed this task from Incorrect gitiles git clone url to "git clone" URL shown on gitiles is incorrect, triggers "Permission denied (publickey)" error.Mar 8 2018, 12:32 PM

Apparently in gitiles it seems to only generate the ssh url without the users username.

Framawiki renamed this task from "git clone" URL shown on gitiles is incorrect, triggers "Permission denied (publickey)" error to Gitiles should add username in git clone links, triggers "Permission denied (publickey)" error.Aug 11 2018, 11:55 AM
Framawiki updated the task description. (Show Details)

I believe the reason this appears to not affect everyone, is that:

  1. If you have the same Git shell username on your local command-line, then this "just works".
  1. If you have shell access to Toolforge, WMCS, or WMF production; then you tend to have SSH configuration set, which naturally makes this work.

For example (sshconfig file):

.sshconfig
Host gerrit.wikimedia.org
    Port 29418
    User krinkle

Another trick I use is (gitconfig file):

.gitconfig
[url "ssh://gerrit.wikimedia.org:29418/"]
	insteadOf = https://gerrit.wikimedia.org/r/

It would be nice to have a copy-pastable personalised zero-configuration snippet. This is only being discussed in this, though, because Gerrit/Gitiles could potentially present that in a dynamic way. However, in all other places where we write tutorials or document developer instructions we'd generally not have that option. As such, it might make sense to solve this in the above way rather than through a personalised shell command. Especially because we'd still run into this issue through e.g. https://www.mediawiki.org/wiki/Gerrit/Tutorial/tl;dr and other such guides.

I recognise that Git is used much more widely, but for those that use Git over SSH (as opposed to HTTPS), this might be a more scalable option.