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:

1
2
3
4
5
6
7
$ 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

1
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:

1
eval `ssh-agent -s`

or:

1
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:

1
chmod 0400 ~/.ssh/id_rsa