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

Git credentials and SSH agent not forwarded when connected through SSH #5977

Closed
chrmarti opened this issue Dec 1, 2021 · 8 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers
Milestone

Comments

@chrmarti
Copy link
Contributor

chrmarti commented Dec 1, 2021

I have been doing some initial testing and things are mostly working for me. Really nice job on this. I have one issue with git credentials. When running a devcontainer locally it will pick up the git credentials from the local OS if a credentials manager is configured (https://code.visualstudio.com/docs/remote/containers#_using-a-credential-helper). That does not appear to be happening when opening the container from a remote SSH connection. @chrmarti, Any guidance on this?

Originally posted by @hansenms in #2994 (comment)

@chrmarti chrmarti self-assigned this Dec 1, 2021
@chrmarti chrmarti added bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers labels Dec 1, 2021
@chrmarti chrmarti added this to the November 2021 milestone Dec 1, 2021
@chrmarti
Copy link
Contributor Author

chrmarti commented Dec 1, 2021

/fyi @felipecrs for the SSH agent forwarding.

@zweiter
Copy link

zweiter commented Dec 2, 2021

The same is happening for me when using Remote SSH into any Linux system. I need to set SSH_AUTH_SOCK as explained in the issue #2671 that has been closed last year.

@chrmarti
Copy link
Contributor Author

chrmarti commented Dec 2, 2021

@zweiter This is about the Remote-Containers extension. Could you open a new issue for the problem with Remote-SSH?

@chrmarti chrmarti closed this as completed Dec 2, 2021
@felipecrs
Copy link

felipecrs commented Dec 2, 2021

Hey @chrmarti, I think you hit "Close" by mistake.

@hansenms
Copy link

hansenms commented Dec 2, 2021

I have an update on this. I have been experimenting some more and I have managed to somehow get git credentials to pass through. For one project I was testing it wasn't working and for another one it mysteriously appears to be working. I can't figure out the mechanics of it, but here is what I see:

I had an initial repo I was working on and to get things working, I installed the git credentials manager insider the devcontainer and that worked. Then I started a new repo and with its own devcontainer, that one seems to have picked up the settings from the other one....inside the second container, I get:

$ git config --global --list
credential.helper=!f() { /home/vscode/.vscode-server-insiders/bin/827f76521d33a61c19e92160649a0a6af8bad132-insider/node /tmp/vscode-remote-containers-e32ee6de56cec72419439a022d313eca32535d00.js $*; }; f
credential.credentialstore=cache
credential.cacheoptions=--timeout 86400
credential.https://dev.azure.com.usehttppath=true
user.name=XXXX
[email protected]

I am (almost) 100% sure I did not install anything in the second devcontainer to support this.

@chrmarti
Copy link
Contributor Author

chrmarti commented Dec 3, 2021

It will use the SSH server's Git credential helper if there is one. I have a fix ready that will make it consult localhost's credential helper if the one on the SSH server fails.

Similarly for the ssh-agent, if the SSH server does not have SSH_AUTH_SOCK set, the fix will check for it on localhost.

@interpeix
Copy link

I'm in the same situation.
My laptop (Windows machine with Git installed and GCM) and GCM is not forwarded to Remote-SSH Host.

Scenario 1:
My Laptop => Remote-SSH to linux host, trying to clone a repo that have the credentials saved on the windows machine fails.
$ git config --get credential.helper empty reply

Scenario 2:
Manually upload the content of the repository to the SSH Host, because there is a .devcontainer that I want to run.
My Laptop => Remote-SSH to linux host => Reopen folder remote container works without issues.
$ git config --get credential.helper Returns
!f() { /root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/node /tmp/vscode-remote-containers-673b0b90a3ad4447008f875661559991d7fdb747.js $*; }; f

Is there any workaround to be able to forward de GCM to the Remote-SSH host?

@chrmarti
Copy link
Contributor Author

Created #6168 for @interpeix 's request.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers
Projects
None yet
Development

No branches or pull requests

5 participants