Skip to content

Instantly share code, notes, and snippets.

@anguschiu1
Last active July 7, 2020 02:45
Show Gist options
  • Save anguschiu1/3cbace48624349e94861af22cdfa0716 to your computer and use it in GitHub Desktop.
Save anguschiu1/3cbace48624349e94861af22cdfa0716 to your computer and use it in GitHub Desktop.
[How to let Ubuntu trust self-signed root CA for Git] #git #cli #linux

Let Ubuntu on Windows trust self-signed root CA for Git

Source

Concepts

  • Go to /usr/local/share/ca-certificates/
  • Create a new folder, i.e. sudo mkdir git
  • Copy the .crt file of the Root CA SSL certificate (retrieve separately) into that git folder
  • Make sure the permissions are OK (755 for the folder, 644 for the file)
  • Run "sudo update-ca-certificates" to update /etc/ssl/certs and ca-certificates.crt
  • Setup Git config

Steps

  • Install Windows Ubuntu subsystem
  • Open and setup a root password
  • On Windows Explorer, create a folder under user directory, e.g. C:\Users\<your_domain_id>\dev
  • On Ubuntu, go to mount /mnt/c/Users/<your_domain_id>/dev by command
cd /mnt/c/Users/<your_domain_id>/dev
  • Run this:
sudo apt-get install --reinstall ca-certificates
sudo mkdir /usr/local/share/ca-certificates/git
cp /mnt/c/Users/<your_domain_id>/dev/YOUR-ROOT-CA.crt /usr/local/share/ca-certificates/git
sudo update-ca-certificates
git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt
  • Git clone repository to local
git clone https://<your_git_server>/scm/<your_domain_id>/YOUR-REPO.git

(Optional) You can cache your password to memory on Ubuntu by setting

git config --global credential.helper 'cache --timeout=3600'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment