Prerequisites

Installing GitHub CLI

archlinux:

1
sudo pacman -S github-cli

windows:

1
winget install -e --id GitHub.cli

Connect with SSH

Checking for existing SSH keys

1
ls -al ~/.ssh

Generating a new SSH key if public SSH key doesn’t exist

1
ssh-keygen -t ed25519 -C "csyezheng@gmail.com"

Adding your SSH key to the ssh-agent (optional)

1
eval "$(ssh-agent -s)"
1
ssh-add ~/.ssh/id_ed25519
1
ssh-add -l

Adding a new SSH key to your account

1
gh auth login
1
gh ssh-key add ~/.ssh/id_ed25519.pub

Testing your SSH connection

1
ssh -T git@github.com

Proxy for SSH URLs

edit the file at ~/.ssh/config, and add this section:

windows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Host github.com
	HostName github.com
	Port 22
    User git
	IdentityFile "C:/Users/ye/.ssh/id_rsa"
	TCPKeepAlive yes
    ServerAliveInterval 60
    ServerAliveCountMax 3
	ProxyCommand "C:\Program Files\Git\mingw64\bin\connect" -S 127.0.0.1:10808 -a none %h %p
	
Host ssh.github.com
	HostName ssh.github.com
    Port 443
    User git
	IdentityFile "C:/Users/ye/.ssh/id_rsa"
	TCPKeepAlive yes
    ServerAliveInterval 60
    ServerAliveCountMax 3
	ProxyCommand "C:\Program Files\Git\mingw64\bin\connect" -S 127.0.0.1:10808 -a none %h %p

Linux:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Host github.com
	HostName github.com
	Port 22
    User git
	IdentityFile "/home/username/.ssh/id_rsa"
	TCPKeepAlive yes
    ServerAliveInterval 60
    ServerAliveCountMax 3
	ProxyCommand nc -v -x proxyhost:port %h %p
	
Host ssh.github.com
	HostName ssh.github.com
    Port 443
    User git
	IdentityFile "/home/username/.ssh/id_rsa"
	TCPKeepAlive yes
    ServerAliveInterval 60
    ServerAliveCountMax 3
	ProxyCommand nc -v -x proxyhost:port %h %p

username and password for your proxy

1
2
# ~/.ssh/myauth
proxyUsername:proxyPassword
1
2
3
# ~/.ssh/config
	...
	ProxyCommand nc -v -x proxyhost:port %h %p ~/.ssh/myauth

You can test that this works by connecting once more to GitHub.com:

1
2
$ ssh -vT -p 22 git@github.com
$ ssh -vT -p 443 git@ssh.github.com

clone the repository using SSH:

1
git clone ssh://git@github.com/YOUR-USERNAME/YOUR-REPOSITORY.git

clone the repository using SSH over the HTTPS port:

1
git clone ssh://git@ssh.github.com:443/YOUR-USERNAME/YOUR-REPOSITORY.git

Proxy for HTTPS URLs

You can configure these globally in your user ~/.gitconfig file using the --global switch, or local to a repository in its .git/config file.

Setting a global proxy

1
git config --global http.proxy protocol://user:password@proxyhost:port

URL specific proxy

1
git config --global http.https://domain.com.proxy protocol://user:password@proxyhost:port

Whether to verify the SSL certificate when fetching or pushing over HTTPS.

1
git config --global http.https://domain.com.sslVerify false

Setting http.<url>.sslVerify to false may help you quickly get going if your workplace employs man-in-the-middle HTTPS proxying. Longer term, you could get the root CA that they are applying to the certificate chain and specify it with either http.sslCAInfo or http.sslCAPath.

See also the git-config documentation, especially the following sections if you’re having HTTPS/SSL issues

  • http.sslVerify
  • http.sslCAInfo
  • http.sslCAPath
  • http.sslCert
  • http.sslKey
  • http.sslCertPasswordProtected

Handle subsequent SSL protocol errors

1
git -c http.sslVerify=false clone https://domain.com/username/repo.git

Unset a proxy or SSL verification

1
2
3
4
5
git config --global --unset http.proxy
git config --global --unset http.https://domain.com.proxy

git config --global --unset http.sslVerify
git config --global --unset http.https://domain.com.sslVerify

Show current configuration

1
git config --global -l