Issue
I would like to clone a private already existing repo to my local server. I've tried a series of commands to no avail.
[user@BC-01 gitTEST]$ git clone https://github.com/*****/Clinical.git
Initialized empty Git repository in /home/dir/gitTEST/Clinical/.git/
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/*****/Clinical.git/info/refs
fatal: HTTP request failed
[user@BC-01 gitTEST]$ git clone https://user:[email protected]/*****/Clinical.git
Initialized empty Git repository in /home/dir/gitTEST/Clinical/.git/
error: The requested URL returned error: 403 Forbidden while accessing https://user:[email protected]/*****/Clinical.git/info/refs
fatal: HTTP request failed
[user@BC-01 gitTEST]$ git clone [email protected]:*****/Clinical.git
Initialized empty Git repository in /home/dir/gitTEST/Clinical/.git/
The authenticity of host 'github.com (192.30.252.130)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.130' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
How can I get this private repo cloned?
Solution
I recommend using SSH key authentication, so you do not need to type in your login and password everytime you connect to GitHub. First follow the documentation to setup SSH authentication.
Then use the clone command with SSH link to your repo and it should work.
[user@BC-01 gitTEST]$ git clone [email protected]:<username>/Clinical.git
Answered By - thegeko Answer Checked By - Katrina (WPSolving Volunteer)