Skip to content

Commit 237321c

Browse files
authored
Merge pull request #7834 from PRO-2684/main
sharing-git-credentials: Simplify `ssh-add`; Add note for enabling agent forwarding
2 parents 21d0d61 + e3ae9c7 commit 237321c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

remote/advancedcontainers/sharing-git-credentials.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ If you use HTTPS to clone your repositories and **have a [credential helper conf
2929

3030
There are some cases when you may be cloning your repository using SSH keys instead of a credential helper. To enable this scenario, the extension will automatically forward your **local [SSH agent](https://www.ssh.com/ssh/agent) if one is running**.
3131

32+
First, you should ensure that [SSH agent forwarding](https://www.ssh.com/academy/ssh/agent#ssh-agent-forwarding) is enabled on the **host**. Search for the `AllowAgentForwarding` option in sshd_config (usually located at `/etc/ssh/sshd_config` or `%programdata%\ssh\sshd_config`). If not already, you should set it to `yes` and reload or restart the `sshd` service.
33+
3234
You can add your local SSH keys to the agent if it is running by using the `ssh-add` command. For example, run this from a terminal or PowerShell:
3335

3436
```bash
35-
ssh-add $HOME/.ssh/<your ssh key>
37+
ssh-add
3638
```
3739

40+
It will add the default files (`~/.ssh/id_rsa`, `.ssh/id_dsa`, `~/.ssh/id_ecdsa`, `~/.ssh/id_ed25519`, and `~/.ssh/identity`). If you'd like to specify a key, simply append the path to it after the command.
41+
3842
On Windows and Linux, you may get an error because the agent is not running (macOS typically has it running by default). Follow these steps to resolve the problem:
3943

4044
**Windows**:
@@ -67,9 +71,10 @@ if [ -z "$SSH_AUTH_SOCK" ]; then
6771
ssh-agent -s &> $HOME/.ssh/ssh-agent
6872
fi
6973
eval `cat $HOME/.ssh/ssh-agent` > /dev/null
70-
ssh-add $HOME/.ssh/<your ssh key> 2> /dev/null
74+
ssh-add 2> /dev/null
7175
fi
7276
```
77+
7378
On the last line, replace `<your ssh key>` with your specific ssh key.
7479

7580
For example `ssh-add $HOME/.ssh/id_ed25519 2> /dev/null`

0 commit comments

Comments
 (0)