Skip to content
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

hub clone $org/$repo failing after GitHub deprecates git:// URLs #2937

Closed
bobwhitelock opened this issue Mar 16, 2022 · 3 comments · Fixed by #2939
Closed

hub clone $org/$repo failing after GitHub deprecates git:// URLs #2937

bobwhitelock opened this issue Mar 16, 2022 · 3 comments · Fixed by #2939
Labels

Comments

@bobwhitelock
Copy link

bobwhitelock commented Mar 16, 2022

Command attempted/what happened

Commands like this started failing for me today:

$ hub clone github/hub
Cloning into 'hub'...
fatal: remote error: 
  The unauthenticated git protocol on port 9418 is no longer supported.
Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.

It seems like GitHub has deprecated using git:// URLs, and this change has fully rolled out as of yesterday - from that link given in the error above:

March 15, 2022 | Changes made permanent.We’ll permanently stop accepting DSA keys. RSA keys uploaded after the cut-off point above will work only with SHA-2 signatures (but again, RSA keys uploaded before this date will continue to work with SHA-1). The deprecated MACs, ciphers, and unencrypted Git protocol will be permanently disabled.


This looks like the relevant section of the hub code where these git:// URLs are used as the default in this situation:

url = fmt.Sprintf("git://%s/%s/%s.git", host, owner, name)

Workaround

You can work around this by either cloning with a full, non-git:// URL:

$ hub clone https://github.com/github/hub
Cloning into 'hub'...
remote: Enumerating objects: 20316, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 20316 (delta 4), reused 11 (delta 2), pack-reused 20300
Receiving objects: 100% (20316/20316), 7.08 MiB | 1.04 MiB/s, done.
Resolving deltas: 100% (13286/13286), done.

Or by setting this config value so hub uses a different protocol by default:

$ git config --global hub.protocol https  # Or `ssh` if you prefer that.
$ hub clone github/hub
Cloning into 'hub'...
remote: Enumerating objects: 20316, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 20316 (delta 4), reused 11 (delta 2), pack-reused 20300
Receiving objects: 100% (20316/20316), 7.08 MiB | 1.08 MiB/s, done.
Resolving deltas: 100% (13286/13286), done.

So this is easy to work around, just a bit confusing when it first happens, and no longer seems like useful default behaviour.

More info

$ hub --version
git version 2.35.1
hub version 2.14.2
$ uname -o 
GNU/Linux
$ uname -r
5.15.22-1-lts
bobwhitelock added a commit to bobwhitelock/dotfiles that referenced this issue Mar 16, 2022
bobwhitelock added a commit to bobwhitelock/dotfiles that referenced this issue Mar 16, 2022
bobwhitelock added a commit to bobwhitelock/dotfiles that referenced this issue Mar 16, 2022
Following
https://github.blog/2021-09-01-improving-git-protocol-security-github/,
this allows pull to continue working in all already cloned repositories
without needing to change their remotes (especially since many of these
will have automatically been cloned with `git://` URLs due to
github/hub#2937).
@mislav
Copy link
Member

mislav commented Mar 16, 2022

Great point. The workaround you've discovered is the correct one:

git config --global hub.protocol https  # Or `ssh` if you prefer that.

And I agree that hub should change its default protocol.

@dsyer
Copy link

dsyer commented Mar 17, 2022

It's a workaround still IMO because when I clone a repo that I own (and therefore have write access) I want to use ssh. Hub would do that automatically if the global protocol wasn't set. Now I have to faff around changing the remote url for every project I clone or create. Please can we fix this?

@mislav
Copy link
Member

mislav commented Mar 17, 2022

@dsyer If you prefer SSH then please use git config --global hub.protocol ssh.

fricklerhandwerk added a commit to fricklerhandwerk/.config that referenced this issue Mar 18, 2022
fixes the following error
```
hub clone ...
fatal: remote error:
  The unauthenticated git protocol on port 9418 is no longer supported.
```

github/hub#2937
halostatue added a commit to halostatue/hub that referenced this issue Mar 20, 2022
Resolves github#2937

- When `HUB_`PROTOCOL or `hub.protocol` are not specified, default to
  `https` instead of `git`, which has been deprecated by GitHub.

  ```sh
  $ hub clone github/hub
  Cloning into 'hub'...
  fatal: remote error:
    The unauthenticated git protocol on port 9418 is no longer supported.
  Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
  ```

Explicitly setting `hub.protocol` to `git` or using `HUB_PROTOCOL=git`
still uses the `git` protocol.
jeremyschlatter added a commit to jeremyschlatter/env that referenced this issue Mar 20, 2022
See github/hub#2937

My 'clone' command broke, for the reasons described in that issue. The
workaround is to set the default protocol to https or ssh. https (which
seems like it will become the new hub default) won't work for me since I
sometimes use this command to clone private repos. So I'm setting it to
ssh.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants