Skip to content

Commit 78045d4

Browse files
authored
Update ssh repo clone docs (#669)
<!-- Explain the changes introduced in your PR --> ## Pull Request approval Although pull request approval is not enforced for this repository in order to reduce friction, merging without a review will generate a ticket for the docs team to review your changes. So if possible, have your pull request approved before merging.
1 parent bcb856d commit 78045d4

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

docs/admin/code_hosts/aws_codecommit.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,24 @@ To add CodeCommit repositories in Docker Container:
8787
1. Follow the rest of the steps detailed in the [AWS SSH setup guide](https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-ssh-unixes.html) to make sure you can connect to the code host locally.
8888
1. Confirm you have the connection by running the following ssh command locally: `ssh git-codecommit.us-west-1.amazonaws.com` (Update link with your server region)
8989
1. Confirm you can clone the repository locally.
90+
91+
### Configuring SSH credentials in the Web UI
92+
93+
```json
94+
{
95+
"gitURLType": "ssh",
96+
"gitSSHKeyID": "<SSH key ID>",
97+
"gitSSHCredential": {
98+
// make sure the key is base64 encoded
99+
// $ cat ~/.ssh/id_rsa | base64
100+
"privateKey": "<base64 encoded of the SSH private key>",
101+
"passphrase": "<passphrase if applicable, omit if none is needed>"
102+
}
103+
}
104+
```
105+
106+
### Mounting SSH keys into the container
107+
90108
1. Copy all the files at your `$HOME/.ssh directory` to `$HOME/.sourcegraph/config/ssh` directory. See [docs](/admin/deploy/docker-single-container/#ssh-authentication-config-keys-knownhosts) for more information about our ssh file system.
91109
1. Read our [guide here](/admin/deploy/docker-compose/#git-ssh-configuration) for Docker Compose deployments
92110
1. Read our [guide here](/admin/deploy/kubernetes/configure#ssh-for-cloning) for Kubernetes deployments

docs/admin/repo/auth.mdx

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,47 @@ If authentication (HTTP(S) or SSH) is required to `git clone` a repository then
44

55
First, ensure your **Site admin > Manage code hosts** code host configuration is configured to use SSH. For example, by setting the `gitURLType` field to "ssh". Alternatively, you may use the "Generic Git host" code host type, which allows you to directly specify Git repository URLs for cloning.
66

7-
Then, follow the directions below depending on your deployment type:
7+
Then, you need to supply the SSH keys and passphrase to Sourcegraph if applicable. You have two options:
8+
9+
- **Option 1**: Configure the SSH credentials in code host configuration in the Web UI. (Recommended)
10+
- **Option 2**: Mount the SSH keys into the container.
11+
12+
## Configuring SSH credentials in the Web UI (Recommended)
13+
14+
In supported code hosts configuration, you can provide the credentials in the JSON configuration. For example:
15+
16+
```json
17+
{
18+
"url": "https://github.com",
19+
"token": "<personal access token>",
20+
"gitURLType": "ssh",
21+
"gitSSHCredential": {
22+
// make sure the key is base64 encoded
23+
// $ cat ~/.ssh/id_rsa | base64
24+
"privateKey": "<base64 encoded of the SSH private key>",
25+
"passphrase": "<passphrase if applicable, omit if none is needed>"
26+
}
27+
}
28+
```
29+
30+
Some providers may require additional configuration, consult the [code host specific documentation](/admin/code_hosts/) for more information.
31+
32+
## Mounting SSH keys into the container
833

934
- [Sourcegraph with Docker Compose](/admin/deploy/docker-compose/): See [the Docker Compose git configuration guide](/admin/deploy/docker-compose/#git-configuration).
1035
- [Sourcegraph with Kubernetes](/admin/deploy/kubernetes/): See [Configure repository cloning via SSH](/admin/deploy/kubernetes/configure#ssh-for-cloning).
1136
- [Single-container Sourcegraph](/admin/deploy/docker-single-container/): See [the single-container git configuration guide](/admin/deploy/docker-single-container/#git-configuration-and-authentication).
1237

13-
>NOTE: Repository access over SSH is not yet supported on [Sourcegraph Cloud](/cloud/).
14-
1538
## Troubleshooting
1639

40+
### Error: `illegal base64 data at input byte 0`
41+
42+
This error indicates that the provided private key is not base64-encoded. Ensure that the private key is base64-encoded before providing it to Sourcegraph.
43+
44+
```bash
45+
cat ~/.ssh/id_rsa | base64
46+
```
47+
1748
### What should be included in my config file?
1849

1950
We recommend adding the `StrictHostKeyChecking no` and `AddKeysToAgent yes` flags to prevent the need to give permission interactively when cloning from a new host.

0 commit comments

Comments
 (0)