cloning private repo using ruby-git

I’m using ruby-git to programmatically perform some operations git repos hosted on GitHub.

Everything works fine when I do it on public repos however, I’m not able to clone private repos even if I have created an ssh key on the machine when the code runs and added the public one on GitHub. To make sure the key is properly setup I have cloned the repo directly from the terminal and the repo was successfully cloned. The key has also been added to the ssh-agent and $SSH_AUTH_SOCK is set.
So, I think the issue is related to how I use the ruby-git gem.

Here my (simple) code

@repo = Git.clone("git@github.com:#{repo_full_name}.git", path)

And here, if it may be helpful teh error

 Git::GitExecuteError: git clone '--' 'git@github.com:USER/REPO.git' '/var/www/repo-root/USER/REPO' 2>&1:Cloning into '/var/www/repo-root/USER/REPO'... Permission denied (publickey). fatal: Could not read

Am I missing anything here?

Thanks


Source: ruby

Leave a Reply