Reputation: 39483
I've created a Visual Studio Code development container. Everything is working fine, it is a very cool technology, but it fails to push my committed code to an external Git server. I'm trying to push to BitBucket, but the problem would be the same with GitHub.
When I try to push from the terminal, I get this error message:
$ git push
ssh: connect to host bitbucket.org port 22: Cannot assign requested address
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
And when I try to push using VSCode Git tab commands, the errors are more complete:
Please make sure you have the correct access rights
and the repository exists.
> git ls-tree -l HEAD -- /workspaces/xxxx/.devcontainer/Dockerfile
> git show --textconv HEAD:.devcontainer/Dockerfile
> git push origin master:master
ssh: connect to host bitbucket.org port 22: Cannot assign requested address
fatal: Could not read from remote repository.
If I reopen locally my workspace, the push works as usual.
I thought this configuration was automatic. My remote repo is connected using ssh.
What must I configure to be able to push my code?
Upvotes: 2
Views: 5292
Reputation: 730
In my case, to push to remote repo inside dev container, I made the following changes and it worked.
ForwardAgent yes
is in your ~/.ssh/config
file.ssh-add ~/.ssh/github_rsa
eval "$(ssh-agent -s)"
echo $SSH_AGENT_SOCK
, and make sure it's not an empty stringgit
and sshd
in your devcontainer.json file.devcontainer.json
"features": {
"git": "os-provided",
"sshd": "latest"
},
Reference: Remote Container Using SSH keys
Upvotes: 0
Reputation: 39483
Ops! Wrong question. It looks like my ISP decided to block my outbound connections to port 22. Argh!!! I didn't expect it.
I discovered that both GitHub and BitBucket have clever workarounds to neurotic sysadmins.
Just add these configurations to your ~/.ssh/config
file and make your ssh connections to the external Git servers go through the unblockable https port 443:
Host github.com
Hostname ssh.github.com
Port 443
Host bitbucket.org
Hostname altssh.bitbucket.org
Port 443
Here are some extra tips for sharing your ssh credentials with the container when using VSCode.
Upvotes: 3
Reputation: 1
My guess is you need to forward the Port of the Docker Container.
On the bottom left there should be something like this link to Image
Click on the one that says no Ports Forwarded (Right one) and ten forward the port 22.
Upvotes: 0