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

devcontainer.json option to forward SSH agent or provide SSH keys inside the container #106

Closed
mhofman opened this issue May 4, 2019 · 7 comments
Assignees
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@mhofman
Copy link

mhofman commented May 4, 2019

It would be great to have a built-in option in devcontainer.json that automatically sets up "SSH Agent forwarding" if an SSH Agent is available locally.

Right now on Linux one needs to add the following, for example:

    "runArgs": [
        "-v",
        "${env:SSH_AUTH_SOCK}:/tmp/ssh-agent.socket",
        "-e",
        "SSH_AUTH_SOCK=/tmp/ssh-agent.socket"
    ]
@kieferrm kieferrm added the containers Issue in vscode-remote containers label May 4, 2019
@egamma egamma added the feature-request Request for new features or functionality label May 6, 2019
@chrmarti
Copy link
Contributor

chrmarti commented May 7, 2019

This might enable Git repositories with ssh connections. (Need to test.)

@Chuxel
Copy link
Member

Chuxel commented Jun 10, 2019

Related to #16.

@Chuxel Chuxel changed the title devcontainer.json option to forward SSH agent devcontainer.json option to forward SSH agent or provide SSH keys inside the container Jul 12, 2019
@Chuxel
Copy link
Member

Chuxel commented Jul 12, 2019

@chrmarti I tried getting this working outside of Linux and wasn't successful. There's an open issue in Docker for Mac on it: docker/for-mac#410

To make matters worse, on macOS, you can mount your SSH keys, but that doesn't work on Docker for Windows due to the permissive levels of bind mounts. ☹️

At this point, I documented a copy-hack where you mount into a separate folder and then use postCreateCommand to copy to the correct location. We probably do need some sort of way to do this easily -- maybe we break down and provide an option to copy from .ssh like we do for .gitconfig but behind an opt-in flag (or I guess a prompt)

@wkornewald
Copy link

wkornewald commented Aug 26, 2019

As a workaround I've implemented ssh-agent-inject. Feedback would be welcome.

@chrmarti
Copy link
Contributor

Thanks @wkornewald . I have found a JavaScript library helping with this (muxrpc) so we don't need native binaries for the different platforms.

@chrmarti
Copy link
Contributor

@Chuxel FYI, our documentation will need an update: You can now add an SSH key to the local SSH agent and that will be available in the container. A prerequisite on Mac and Linux is that the environment variable SSH_AUTH_SOCK is set locally and available in VS Code. On Windows 10 it's enough for the ssh-agent (registered as a built-in service) to run (it's disabled by default) on the default socket path \\.\pipe\openssh-ssh-agent.

@chrmarti chrmarti added the verification-needed Verification of issue is requested label Dec 3, 2019
@alexr00
Copy link
Member

alexr00 commented Dec 4, 2019

Verified on Windows by opening a new devcontainer then using the terminal to ssh.

@alexr00 alexr00 added the verified Verification succeeded label Dec 4, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

7 participants