Skip to content

[Bug/Feature Request] Dev Container: SSH keys from host are not accessible #82

@SebastianGrob

Description

@SebastianGrob

Description:

Currently, when I launch a dev container, I encounter Permission denied (publickey) errors when attempting to perform Git operations. This issue stems from the ~/.ssh/ directory within the dev container being empty, as it is not automatically mounted or linked to my host's SSH configuration.

On the host machine, Git operations function correctly, as my SSH keys are properly set up in ~/.ssh/. To maintain a seamless workflow and avoid reconfiguring SSH within each dev container, it would be highly beneficial if the dev container environment could automatically leverage the host's SSH agent or mount the ~/.ssh/ directory.

Steps to Reproduce:

  1. Ensure SSH keys are configured in ~/.ssh/ on the host.
  2. Build and enter the dev container.
  3. Execute any Git command that requires authentication (e.g., git fetch, git push).

Expected Behavior:

Git commands within the dev container should authenticate successfully using the host's SSH keys, without requiring manual setup inside the container.

Actual Behavior:

Git commands fail with an authentication error: Permission denied (publickey).

Potential Solutions (if applicable):

  • Automatically mount ~/.ssh/ from the host, e.g. adding to devcontainer.json something like
"runArgs": [
    "-v", "${localEnv:HOME}${localEnv:USERPROFILE}/.ssh:/home/vscode/.ssh"
    ]
  • Integrate with the host's SSH agent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions