July 2013
« Jun   Aug »

GitHub : fatal: Could not read from remote repository.

One of the production server is being updated from Github directly as one of the user deployed files from git checkout. This is done for their easiness and no need to transfer the files every time if there is an update occurs. This is REALLY a BAD idea to use production space having version control files. There must be place Continuous integration there.

The user one who had set this up had left the company and hence his account is deleted from Github account too. When somebody trying to execute git pull origin

[user1@server1 public_html]$ git pull origin live
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

This means the current ssh public_key is does not allow to access the Git repo. So they are stuck at this point.


We need to authorize the private key with git hub account. There is two way,
1. Take a copy of current private key from the logged user account (~/.ssh/id_rsa) and added this key in that project GotHub repo.
2. Copy the .ssh profile directory (/home/user1/.ssh) from any of active user who allow to access this repo and replace it with remote production user ssh profile folder (/home/produser/.ssh)
if you have ssh access in between the server apply the following command from user desktop,
Eg: scp -r ~/.ssh prod-user@serverip:/home/produser/

How to test

Go to the earlier git checkout folder and execute pull command again

[user1@server1 ~]$ cd public_html
[user1@server1 public_html]$ git pull origin live
remote: Counting objects: 39, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 26 (delta 11), reused 26 (delta 11)
Unpacking objects: 100% (26/26), done.
 * branch            live       -> FETCH_HEAD
Updating 6fbee0b..5d41d99
 skin/frontend/base/default/feedback/css/popup.css      |   4 ++--
 .../feedback/images/homepage_sprites_image1.png  | Bin 0 -> 104046 bytes
 .../frontend/default/project1/css/common-style.css |  15 +++++++++++----
 3 files changed, 13 insertions(+), 6 deletions(-)
 create mode 100644 skin/frontend/base/default/feedback/images/homepage_sprites_image1.png
[user1@server1 public_html]$

The above technique was a hack.So don’t try unless have access to “deployment keys” area in Github account.

Reliable solution [Recommended]

If you have a continuous integration (CI) system or you want a permanent git hub access from productiom server, Better to use the GitHub mechansm “Deployment keys” This option will be available only on project owner account. So the key will be valid till the project exist.

How to generate deployment key

[liju@web-test1 ~]$ mkdir -p  ~/.ssh/ && cd ~/.ssh
[liju@web-test1 .ssh]$ ssh-keygen -t rsa -C ""
Generating public/private rsa key pair.
Enter file in which to save the key (/home/liju/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/liju/.ssh/id_rsa.
Your public key has been saved in /home/liju/.ssh/
The key fingerprint is:
[liju@web-test1 .ssh]$ cat /home/liju/.ssh/
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzEzwM2ppIVWYCMHtRYajGIMeNFldk1R9z9SGW5vfTRgK3OTToEI4Zg8r4xtmJ3cR+X+GRT6yFnMbN0nIOPy/rm1rn0agmkxnw1zph2ghab8JCNZRPEXkcTC07jk1a5Mfn9OU04PT20a21ic8uXbVYTdFF0Zuu2xuQ==

I do no use passPhase here. Just copy the content of from .ssh folder and paste it on Deployment keys in Github account.

1. Go to your Account Settings
2. Click “SSH Keys” in the left sidebar
3. Click “Add SSH key”
4. Paste your key into the “Key” field
5. Click “Add key”

How do I test the deployment key is active.

Try to checkout the project from Git

[liju@mail test]$ [iclt@mail test]$ ssh -T
Hi Serveridol/sample! You've successfully authenticated, but GitHub does not provide shell access.
[iclt@mail test

🙂 !! Simple trick ! with minimal impact

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>