-2

I have a repository that was initialized using HTTPS and am trying to switch it over to SSH. I'm working on a computer running Pop!_OS which is basically Ubuntu. I have generated keys following these instructions: https://gist.github.com/zhujunsan/a0becf82ade50ed06115

When I try to test the connection using sudo -u axiomtutor ssh -T git@github.com it says my user is unknown. Which seems strange because I have set my user name globally in the terminal. When I try to push I get

ERROR: Permission to axiomtutor/asking.git denied to deploy key fatal: Could not read from remote repository.

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

The content of my local .git/config file looks like:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = git@github.com:me/repo.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

I've run the ssh-agent and entered ssh-add -k ... to add my SSH key to the path. I've put the key in the "Deploy Key" section of the settings on my repo. So I'm just not seeing what the issue could be.

Following these instructions didn't change anything:

Switching Git to use SSH

Addem
  • 3,118
  • 3
  • 24
  • 47
  • 2
    What happens if you run `ssh git@github.com`? It should reply `Hi ! You've successfully authenticated, but GitHub does not provide shell access.`. If you get an error, you simply have an ssh configuration problem: either you've loaded the wrong key into your agent, or the key(s) in your agent aren't configured on the remote repository (or maybe you're trying to push when your deploy key has only read privileges). – larsks Sep 20 '20 at 15:28
  • Could you try to clone the repository in another folder using a new shell? Sometimes the shell is buggy after several ssh attempts – JRichardsz Sep 20 '20 at 15:56
  • 1
    Is your SSH key owned by you or by `axiomtutor`? Is it owned by the same user as is performing the Git operation? – bk2204 Sep 20 '20 at 16:27
  • @larsks It does reply with the message you wrote, but when I try to push it still says permission denied. I just created a new key and put it in the "Deploy Keys" list, and all that stuff, with write permission, etc. Any ideas? – Addem Sep 20 '20 at 16:36
  • @larsks Wait, actually it has the message you wrote but just above that I'm seeing it also says "PTY allocation request failed on channel 0". – Addem Sep 20 '20 at 16:38
  • I found this: https://stackoverflow.com/questions/27021641/how-to-fix-request-failed-on-channel-0/30191214 And tried instead entering `sudo ssh git@github.com`. Now it says permission denied. I wonder if somehow I did something as root which should have been done as user? – Addem Sep 20 '20 at 16:42

1 Answers1

-1

Gah, I think I figured it out. Something somewhere didn't work, so I generated a new key. But when I did that, I put it somewhere new, and forgot to correspondingly edit ~/.ssh/config.

Addem
  • 3,118
  • 3
  • 24
  • 47