No access to new repository with active ssh key on profile

Hey all - just joining this group. I am on Endeavour OS (Arch based) and using github for a while to contribute to existing projects. Using the terminal for all git tasks…

I am now in trouble again since the access to github is only available with access token or ssh key. When i created a new repository I cannot push to it - somehow the ssh key in my github profile is only recognized for existing repositories. I could yet again create another ssh key but there must be a smarter solution. Couldnt find any help yet in documentation or forum so asking here…

What I have done:

  • create new repository on my git site
  • git clone https://github.com/...
  • changed to directory
  • made changes
  • git add --all
  • git commit -m "Initial commit"
  • git push -u origin main

now it doesn’t ask for the passphrase for the ssh key but instead for git username and password which doesnt work since summer

$ git push -u origin main
Username for 'https://github.com': toszlanyi
Password for 'https://toszlanyi@github.com': 
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentifizierung fehlgeschlagen für 'https://github.com/xyz-repo'
$ ssh -vT git@github.com
OpenSSH_8.8p1, OpenSSL 1.1.1l  24 Aug 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [140.82.121.4] port 22.
debug1: Connection established.
...
debug1: Offering public key: /home/osz/.ssh/id_ed25519 ED25519 SHA256: ...
debug1: Server accepts key: /home/osz/.ssh/id_ed25519 ED25519 SHA256: ...
Enter passphrase for key '/home/osz/.ssh/id_ed25519': 
Authenticated to github.com ([140.82.121.4]:22) using "publickey".
Hi toszlanyi! You've successfully authenticated, but GitHub does not provide shell access.
$ git remote -v
origin  https://github.com/toszlanyi/xyz-repo (fetch)
origin  https://github.com/toszlanyi/xyz-repo (push)
$ cat .git/config 
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = https://github.com/toszlanyi/xyz-repo
        fetch = +refs/heads/*:refs/remotes/origin/*
        pushurl = https://github.com/toszlanyi/xyz-repo
[branch "main"]
        remote = origin
        merge = refs/heads/main

On my other own or cloned repositories I can push using the ssh key id_ed25519 that is set up correctly in my account settings. Any idea how to push / access the new xyz-repo?
Any help appreciated.

Anyone, who can explain what I missed? Thx.

Your repository is configured with an HTTPS remote URL, not SSH, that’s why it’s not using your SSH key. You can change the URL to SSH like this:

git remote set-url origin git@github.com:toszlanyi/xyz-repo.git

For future reference, when you click the green “Code” button on the repository page you can select the protocol you want to use in the box that comes up to get the right URL.

Wicked! Thanks for pointing into the right direction. Your line only changes the fetch url though. But with option --push it also changes the other url.

git remote set-url --push origin git@github.com:toszlanyi/xyz-repo.git
1 Like

Peculiar, in my experience it changes both unless you use one of the flags. I wonder if behavior changed between versions?