1

I am a GCP user. I have a VM that is running in GCP.

But recently, when I try to run the "git pull" or "git fetch" commands to update my project, it just hung there, and there are no responses.

My project is on GitHub.
It worked very well a few weeks ago. I didn't change any ssh or network config.

Not sure what kind of problem it is. I will appreciate it if anyone could give some advice.

Louis Hong
  • 41
  • 1
  • 6

2 Answers2

2

I found the problem and resolved it. Hope this can help other people who faced the same issue as mine.

This was my ssh config file

Host github.com
      HostName github.com
      PreferredAuthentications publickey
      IdentityFile ~/.ssh/id_rsa
      AddKeysToAgent yes

After I removed the line AddKeysToAgent yes, it works now. I don't know why it worked before.

Louis Hong
  • 41
  • 1
  • 6
1

First, you need to make sure if you are indeed using ssh on GCP in your repository folder:

cd /path/to/repository
git remote -v
# Check the URL is
# git@github.com:you/yourRepository
#              ^^^ (note the :)
# Or:
# ssh://git@github.com/you/yourRepository
#                    ^^^ (note the /)

Check also your environment variables:

env|grep -i SSH

(A GIT_SSH... environment variable might affect how Git operates with SSH)

And see if the network route is still opened from your GCP shell to GitHub:

curl -v telnet://github.com:22
# You should see
Connected to github.com (140.82.121.3) port 22 (#0)

For testing, check if you can use (while entering your GitHub account and a GitHub Personal Acccess Token or PAT) use HTTPS:

git ls-remote https://github.com/You/yourRepository

If you are using SSH, activate traces on SSH ,and on Git itself with TRACE2:

export GIT_SSH_COMMAND='ssh -Tv'
GIT_TRACE2_EVENT=1 git pull
# or
GIT_TRACE2=1 git pull

As noted in the OP Louis Hong's answer, activating the traces would show the step where, by tring to add a key to an ssh-agent (from the ~/.ssh/config), said ssh-agent might request a passphrase for another (encrypted) key, thereby hanging on stdin.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you so much for the answer! Yes, I am sure I am using ssh in my repository. I also use `curl -v telnet://github.com:22` to check the network, it works and the result is just like you posted. Checked my `env`, and there is no variable with the prefix `GIT_SSH`. – Louis Hong Jul 13 '22 at 05:13
  • I also logged in with my GitHub account and Personal Access Token, and it succeed. But `git fetch` and `git pull` are still not working. – Louis Hong Jul 13 '22 at 05:15
  • @LouisHong Did you HTTPS clone it on GCP, with the same GCP account than the one used when doing a git pull/fetch. And those pull/fetch are done from the newly cloned repository folder? – VonC Jul 13 '22 at 05:31
  • @LouisHong I have edited the answer to include traces. – VonC Jul 13 '22 at 05:35
  • Thank you so much! I found there is a problem in my ssh config file. I fixed it and it works now! – Louis Hong Jul 13 '22 at 06:13