Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #9882

Closed
stunited-thien opened this issue May 14, 2024 · 6 comments
Assignees
Labels
containers Issue in vscode-remote containers info-needed Issue requires more information from poster

Comments

@stunited-thien
Copy link

  • 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 stunited-thien changed the title 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 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 May 14, 2024
@vscodenpa vscodenpa added the containers Issue in vscode-remote containers label May 14, 2024
@chrmarti
Copy link
Contributor

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 chrmarti added the info-needed Issue requires more information from poster label May 15, 2024
@stunited-thien
Copy link
Author

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)

@chrmarti
Copy link
Contributor

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

@stunited-thien
Copy link
Author

stunited-thien commented May 17, 2024

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)

@chrmarti
Copy link
Contributor

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?

@vscodenpa
Copy link

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 vscodenpa closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2024
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jul 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
containers Issue in vscode-remote containers info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

3 participants