Deploy from Git after Basic Authentication Deprecation

Hi community,

Beginning August 13, 2021, we will no longer accept account passwords when authenticating Git operations on GitHub.com.
Token authentication requirements for Git operations | The GitHub Blog

I’m actually using Infomaniak hosting for my website and usually use basic authentication with password to pull my commits from Git to my server (connected on server with SSH). It’s gonna be depreciated.

Not very skilled with Git operations and SSH, i tried several times to generate SSH public key on my server to init secure connection with Git server but without success.
May someone could advise me about a solution to keep deploying from Git easily ?

Thanks for your answers !

According to this, you have managed to add a public key:
https://github.com/MartG31.keys

What happens if you run:

ssh git@github.com

I get:

Hi jsoref! You’ve successfully authenticated, but GitHub does not provide shell access.

It’s possible you just need to clone again using ssh.
The lazy instructions are here:
Cloning a repository - GitHub Docs

You can delete your existing clone.

There are fancier steps to convert an existing repo, but frankly, it isn’t worth it unless your repo is huge / your downstream bandwidth is small.

If you have unpublished changes, clone to a different directory and push from the old local directory to the new local clone and then from the new local clone back to github.

The “conversion” really is quite simple.

Either the official way:

  1. Within the local repo, add a new remote with the git+ssh: URL, adjust the default fetch & push remote for each branch, and then (optionally) delete the original https: remote; or
  2. Edit .git/config, and replace the https: URL with the git+ssh: one, wherever it appears.

That’s it. Done.

There are some subtle differences between the https and git+ssh URL formats, but you’d have to figure that out no matter which approach you take.

There’s no need to fiddle with config files to adjust URLs, just use git remote set-url, e.g.:

git remote set-url origin git@github.com:user/repo.git
1 Like

Hi! thanks for your replies.

Thanks jsoref, i finally made my ssh connection work with Git server.
I cloned again my repo in a new directory to try git operations with the new ssh connection and everything is okay. Then i replaced old hosting directory by the new one managing path names and ignored directories…
The thing was i also had to migrate my repo on another Git account by the way…

Regarding last replies i guess there was an easier way to do this but it works now !

Thanks to all :slight_smile:

2 Likes

There are various reasons I don’t give this advice.

Amongst them are that one needs to change the character after github.com from / to :.

There are really too many caveats for it to be worth trying to explain to a beginner how to convert. Sure, it’s cute to be clever, but it really isn’t worth the frustration.

@jsoref

There are far worse gotchas in the “make a new clone” approach. It’s “simpler” only if you haven’t made any stashes, haven’t made any local branches, don’t have any un-pushed commits, and don’t have a rebase or merge in progress. If you have any of those, you need to migrate them to the new cloned repo, which for partial rebases & merges is way more complicated than a few minor config changes.

Amongst them are that one needs to change the character after github.com from / to : .

That applies to git remote paths (host.name:/path/to/repo), but does not apply to git+ssh URLs (git+ssh://host.name/path/to/repo). Just change the https: to git+ssh: (and do not change or remove any /).

I said “replace the URL”, meaning the whole URL, exactly to avoid the implication that it should be chopped about. On the contrary, as the replacement just use the URL that was to going to be used to create a new clone.

On the whole I like @airtower-luna 's answer best, though for me personally I’m happier editing a text configuration file rather than trying to remember all the correct commands. And I can leave the old version as a comment in the config file, in case I screw up.

(The subtlety I alluded to is that it only works for regular repos, not for gists. For gists you need to change the hostname to just github.com and remove the username. And for some really old git repos you might need to trim any trailing / and/or add .git.)

PS: in case you’re wondering, yes git+ssh: and ssh+git: are completely interchangeable. Use whichever you’re comfortable with.

1 Like