If you receive the following error when trying to clone a Git repository:
fatal: Could not read from remote repository.
The full message may look something like this:
$ git clone [email protected]:org/repo.git
Cloning into 'repo'...
Bad owner or permissions on /Users/ao/.ssh/config
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
How to solve this error
ssh-add ~/.ssh/id_rsa
where id_rsa
is a ssh key associated with the repo.
If you get the following error at this stage: Could not open a connection to your authentication agent.
, then you first need to run the following:
eval `ssh-agent -s`
or:
eval $(ssh-agent -s)
Permissions 0777 for ‘/Users/ao/.ssh/id_rsa’ are too open
If you get this permissions error, then you can fix the id_rsa
permissions by doing this:
chmod 0400 ~/.ssh/id_rsa