If authentication is required to git clone a repository then you must provide credentials to the container.
The container consults its own file system (in the standard locations) for SSH configuration, private keys, and known_hosts. Upon container start, it copies all files from /etc/sourcegraph/ssh into its own $HOME/.ssh directory.
To provide SSH authentication configuration to the container, assuming you're using the default --volume $HOME/.sourcegraph/config:/etc/sourcegraph, follow these steps:
- Create files at
$HOME/.sourcegraph/config/ssh/config,$HOME/.sourcegraph/config/ssh/known_hosts, etc., on the host machine as desired to configure SSH. - Start (or restart) the container.
To configure the container to use the same SSH as your user account on the host machine, you can also run cp -R $HOME/.ssh $HOME/.sourcegraph/config/ssh.
The easiest way to specify HTTP(S) authentication for repositories is to include the username and password in the clone URL itself, such as https://user:password@example.com/my/repo. These credentials won't be displayed to non-admin users.
Otherwise, the container consults the $HOME/.netrc files on its own file system for HTTP(S) authentication. The .netrc file is a standard way to specify authentication used to connect to external hosts.
To provide HTTP(S) authentication, assuming you're using the default --volume $HOME/.sourcegraph/config:/etc/sourcegraph, follow these steps:
- Create a file at
$HOME/.sourcegraph/config/netrcon the host machine that contains lines of the formmachine example.com login alice password mypassword(replacingexample.com,alice, andmypasswordwith the actual values). - Start (or restart) the container.