Issues Running 'git clone' from the Terminal
Asked by Ricky Byrd:

I'm running SouceTree (Version 1.6.20.0) from Windows 7 Professional 64-bit SP1. I'm attempting to clone from GitLab.

I've been having some issues getting the 'git clone' command to work from the terminal. Whenever I attempt to achieve this, I'm met with the following error:

\>\>\> Cloning into 'C:_Git'...

\>\>\> Permission denied (publickey).  
\>\>\> fatal: Could not read from remote repository.

\>\>\> Please make sure you have the correct access rights  
\>\>\> and the repository exists.

However, when I attempt the clone from the UI, using the same URL and destination path, it works fine. The only thing I can think of is maybe my private or SSH key needs to be located in a certain location on my machine for the get clone command to work from the terminal. Does anyone have any suggestions or ideas on why this won't work from the terminal? Thanks ahead of time!


Answers:
author: rrudnicki
body: Hi Rick,

I'm not familiar with GitLab, but based into your error, looks like you are trying to clone a repo using a wrong SSH Key (or you don't have one). Make sure you have setup the correct key. The following commands will help you:

ssh-add -l #This will list the keys you have loaded

ssh-add \~/.ssh/id_rsa #Should load the correct ssh key from your user

Regards,

Renato Rudnicki

comments: author: Ricky Byrd
body: Hey Renato,First off, thank you for your response!I would agree with you about using the wrong SSH Key if it weren't for the key working whenever I clone the repository using the UI. It works fine from the UI, but fails from the terminal. I'm assuming the terminal isn't looking in the same place as the UI is though. I do have my authentication agent running, so I'm not sure why the terminal can't find it, but the UI can. user@USER-PC /c/Program Files (x86)/Atlassian/SourceTree$ ssh-add -lCould not open a connection to your authentication agent.user@USER-PC /c/Program Files (x86)/Atlassian/SourceTree$ ssh-add \~/.ssh/id_rsaCould not open a connection to your authentication agent. Currently, I have the keys (private and SSH) sitting on my desktop. I guess I need to figure out how to point the terminal at those keys? Whenever I navigate the terminal to the desktop and attempt the commands again, I receive the same response I listed above.


author: rrudnicki
body: Hi Ricky, Yes, looks your terminal is not finding the keys (maybe you've downloaded in another place?). Try this:ssh-add /path-to-your-ssh-key/Then your ssh-key should be loaded (use the same path key you have setup on sourcetree. Also, we have this documentation that can be useful for you. <https://confluence.atlassian.com/bitbucket/how-do-i-use-ssh-with-sourcetree-282173660.html>Cheers, Renato


author: Ricky Byrd
body: Hey Renato,I gave you suggestion a try, but I still continue to get the open connection error I mentioned:$ ssh-add C:\\Users\\user\\Desktop\\repositoryKeys\\rickyByrdSSHCould not open a connection to your authentication agent.It's weird because I do have Pageant running. It detects if from the UI so I'm not sure why it's not detecting it from the terminal :-\\.


Tags: clone

gitlab

terminal