vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

Dev Containers: error "ssh: connect to host github.com port 22: Connection refused" when using git pull in vscode that is attaching to a runing docker container locally

Open stunited-thien opened this issue 1 year ago • 4 comments

  • VSCode Version: 1.89.1
  • Local OS Version: windows 11
  • Remote OS Version: node:16.18.0-alpine
  • Remote Extension/Connection Type: Dev Containers

I already followed attaching container and sharing git ssh. But I got the above error. Here is the result of each command I used in the attached container to get info:

  • ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-XXXXXXKIFeKn/agent.48633; export SSH_AUTH_SOCK;
SSH_AGENT_PID=48634; export SSH_AGENT_PID;
echo Agent pid 48634;
  • echo $SSH_AUTH_SOCK
/tmp/vscode-ssh-auth-a64e1ad3-e58a-4012-b353-cd26f1e4a27b.sock
  • ps -ef | grep ssh-agent
48634 root      0:00 ssh-agent 
50834 root      0:00 grep ssh-agent

Here is my .giconfig in the attached container:

[user]
	name = myname
	email = [email protected]
[gui]
	recentrepo = F:/my-other-project
[safe]
	directory = F:/my-other-project
	directory = .
[credential]
	helper = "!f() { /root/.vscode-server/bin/dc96b837cf6bb4af9cd736aa3af08cf8279f7685/node /tmp/vscode-remote-containers-a64e1ad3-e58a-4012-b353-cd26f1e4a27b.js git-credential-helper $*; }; f"

Does this issue occur when you try this locally?: No Does this issue occur when you try this locally and all extensions are disabled?: No

stunited-thien avatar May 14 '24 09:05 stunited-thien

Since your local machine is Windows, please only follow the instructions for Windows on your local machine (not the container). E.g., you do not need to start ssh-agent in the container. To check if the connection to the local ssh-agent works, you can run ssh-add -l in the container.

The error you copied suggests that there is a network issue between the container and github.com. It doesn't hint at a problem with the local ssh-agent connection.

chrmarti avatar May 15 '24 07:05 chrmarti

Since your local machine is Windows, please only follow the instructions for Windows on your local machine (not the container). E.g., you do not need to start ssh-agent in the container. To check if the connection to the local ssh-agent works, you can run ssh-add -l in the container.

The error you copied suggests that there is a network issue between the container and github.com. It doesn't hint at a problem with the local ssh-agent connection.

My Windows local runs git fine and the local ssh-agent works (I checked it with ssh-add -l ). Only when I attached and ran my local project via the dev containers, I couldn't run git (even though the Git Graph extension still shows my git graph tree, it just can't use git fetch)

stunited-thien avatar May 17 '24 04:05 stunited-thien

What to you get when running ssh-add -l in the dev container? (Without running ssh-agent in the dev container.)

chrmarti avatar May 17 '24 07:05 chrmarti

What to you get when running ssh-add -l in the dev container? (Without running ssh-agent in the dev container.)

I only followed the above instructions for my window, not the dev container but the result of ssh-add -l ran in both window terminal and container ash was the same: 256 SHA256:YPAqj/Ft6imz8lL9UsI9vbCuWis3a2aVneCo9Uw1SFs [email protected] (ED25519)

stunited-thien avatar May 17 '24 10:05 stunited-thien

If this is your SSH key for GitHub you can test the connection by running ssh -T [email protected] in the container. Does that work?

chrmarti avatar May 27 '24 12:05 chrmarti

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

vscodenpa avatar Jun 03 '24 12:06 vscodenpa