In azure app service Kudu console, it is easy to clone a public git repository using "git clone" command, when it comes to private repository, you may find the same "git clone" command is stuck at "Cloning" step and isn't working any more. This is simply because the repository is a private one and need to be authenticated, in the meanwhile, we need an non-interactive way since Kudu console doesn't support popped-out windows.
There are in total 3 approaches to clone the private git repository:
Approach 1 (Username & Password):
The most obvious way to fix this is to put your username and password in the git URL:
git clone https://$username:$password@github.com/$username/$repo -v
Example:
The side effect is that the user credentials would be saved in the .git/config file and everybody who can access Kudu console will be able to view the password.
Approach 2 (SSH key):
Step 1: Send a GET request to the Kudu site to get the SSH key, the URL looks like: https://xxxx.scm.azurewebsites.net/api/sshkey?ensurePublicKey=1
Step 2: Remove the double quote and add the SSH key in the Github SSH key
Step 3: Go to Kudu console and use the SSH way to clone the repository:
git clone git@github.com:$username/$repo.git
For example:
Approach 3 (Personal Access Token):
This approach is to use "personal access token" created in the github developer settings page: https://github.com/settings/tokens
git clone https://$token@github.com/$username/$repo.git
Example: