microsoft / microsoft/vscode-remote-release

Automatically add SSH keys to ssh-agent

Open
#4,024 29 comments 22 reactions 1 assignee View on GitHub

@chrmarti is already working on this.

Since Nov 25, 2020.

containers feature-request
Dominant language
Dockerfile
Stars
4.2k
Forks
470
Avg merge
1d 1h
Merged PRs (30d)
1

Description

Versions
  • VSCode Version: 1.51.1
  • Local OS Version: macOS 10.15.7
  • Remote OS Version: Debian 10
  • Remote Extension/Connection Type: Docker
Bug description

It appears that the SSH agent is not forwarded correctly to the development container on macOS. Cloning a private git repository on the host over SSH works as expected, but the same git clone within the development container fails:

❯ git clone git@github.com:lsorber/my-private-repo.git  # In dev container
Cloning into 'my-private-repo'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Steps to Reproduce
  1. Create a development container (devcontainer.json spec below).
  2. Try to clone a private git repository over SSH.
devcontainer.json spec:
{
    "name": "entities",
    "image": "continuumio/miniconda3:latest",
    "extensions": [
        "ms-python.python",
        "ms-python.vscode-pylance",
        "ms-toolsai.jupyter",
        "eamodio.gitlens"
    ],
    "settings": {
        "terminal.integrated.shell.linux": "/usr/bin/fish",
        "python.pythonPath": "/opt/conda/envs/entities-env/bin/python",
        "python.terminal.activateEnvironment": false,
        "python.terminal.activateEnvInCurrentTerminal": false
    },
    "postCreateCommand": "./tasks/init.sh devcontainer"  // Installs fish shell and creates conda environment
}
Workaround

Explicitly forwarding the SSH agent in devcontainer.json with the snippet below resolves the issue, but is specific to macOS:

    "mounts": [
        "source=/run/host-services/ssh-auth.sock,target=/run/host-services/ssh-auth.sock,type=bind,consistency=cached"
    ],
    "containerEnv": {
        "SSH_AUTH_SOCK": "/run/host-services/ssh-auth.sock"
    },

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.