GitHub can no longer be pushed or pulled from the repository gitcloneed in the EC2 instance

Asked 2 years ago, Updated 2 years ago, 75 views

I can no longer push or pull from the repository I git clone via github in the Amazon EC2 instance.

As I am a beginner, I may not be able to do so, but I checked for about two days and made a try-and-error, but I would appreciate it if you could let me know without solving it.Thank you in advance.

environment

  • macbook pro
  • terminal
  • Amazon EC2 Instance

What's done

  • Register ssh key to github
  • ssh [email protected] displays the following and the connection succeeds

    Hi[username]!You've successfully authenticated, but GitHub does not
    provide shell access.Connection to github.com closed.
    
  • ssh connection is configured.git remote-v shows the following:

    originssh:// [username]@g ithub.com/ [organization]/[repo].git(fetch)
    origin ssh:// [username]@g ithub.com/ [organization]/[repo].git(push)
    

ssh [email protected] displays the following and the connection succeeds

Hi[username]!You've successfully authenticated, but GitHub does not
provide shell access.Connection to github.com closed.

The ssh connection is configured. git remote-v shows the following:

originssh:// [username]@g ithub.com/ [organization]/[repo].git(fetch)
origin ssh:// [username]@g ithub.com/ [organization]/[repo].git(push)

What's not working (what's troubling)

  • git push origin, sudo git push origin, git push [email protected]: [organization]/[repo].git But all of the following are returned

    Permission denied (publickey).
    fatal —Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    

git push origin, sudo git push origin, git push [email protected]: [organization]/[repo].git But all of the following are returned

Permission denied (publickey).
fatal —Could not read from remote repository.

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

git github amazon-ec2

2022-09-30 13:48

2 Answers

I was hitting the git command on sudo, which caused the user who registered with github to be different from the user who ran ssh.

ssh-T [email protected] It was not sudo when running, so I went to access it with the same user who registered with github, and it seems that I went there.This was due to a lack of understanding of the basics of user switching when executing a command on sudo.

--Questioner's From Comments


2022-09-30 13:48

The URL configured as remote for git appears to have the wrong format.

 git remote set-url origin [email protected]: organization/[repo].git

What happens if you do git pull?


2022-09-30 13:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.