Score:0

Permission denied could not read from remote repository

kr flag

I am attempting to clone a git repo from inside an ubuntu 20 server, but after it permanently adds my ECSDA key, I get the following error:

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

I do have access to it from my local machine, but how do I access that Github repo from this Ubuntu server?

I tried to clone it by running, sudo git clone [email protected]:MyRepo/api-service.git

To to be clear this repository is up on Github and I am inside an ubuntu 20 server trying to clone it.

Is this not a matter of adding the keys from Github?

Jeff avatar
mx flag
Have you tried running the repository clone command in sudo? `sudo su` `git clone user/reponame`
Daniel avatar
kr flag
@Jeff, yes I get the same error.
Daniel avatar
kr flag
@Nmath, hopefully I added more clarity.
Jeff avatar
mx flag
I have a GitHub account. If you would like to share, I can look at the repo and see if there is another key. I can send it to you and hopefully it will work. My github username is oneenterprisestech or you can ask me questions on my website https://oneenterprisestech.github.io
guiverc avatar
cn flag
This is a Ubuntu Core 20 server? The 20 indicates a different server product to the far more widely used 20.04 system (ie. 20 != 20.04 with the different format being used for *snap* only 20 products)
Nmath avatar
ng flag
I don't use git often but whenever I've needed to clone a repo, I navigate to the destination folder and simply run `git clone url://` where `url://` is the `.git` URL. Ex: `git clone https://github.com/KDE/krita.git`
Jeff avatar
mx flag
I've never had to use a key to clone a repository before... Have you considered using HTTP or the GitHub CLI option instead?
Daniel avatar
kr flag
@Jeff, I am using SSH.
Jeff avatar
mx flag
@Daniel Sorry, I meant the other things. I updated the comment.
Nate T avatar
it flag
Is it a github repo? This is the error you get when trying to clone a private repo (or at least very close to it.) Are you positive the repo owner has access permission set to "public?"
hr flag
It sounds like you are looking for [Using SSH agent forwarding](https://docs.github.com/en/developers/overview/using-ssh-agent-forwarding)
Score:0
um flag

Something to consider, the man page for ssh-keygen states that the option -C is for a comment. When I first followed the instructions I went by the assumption implied by the man page; that the comment is just that, nothing but a comment meaningful only to you. So when I generated the key as follows

ssh-keygen -t rsa -b 4096 -C "laptop_to_github_key"

This gave me the error stated in the question. But after I generated the key using the github format, (using my email linked to my github account instead of a personal comment) it worked.

ssh-keygen -t rsa -b 4096 -C "[email protected]"
Score:0
kr flag

Step 1. - From within your Ubuntu server run ssh-keygen -t rsa

Step 2. - From within your Ubuntu server run cat ~/.ssh/id_rsa.pub

Step 3. - Copy and paste the resulting key and paste it into Github account, by going to Settings, then *SSH and GPG section and click the New SSH key button.

Step 4. - Go back to your Ubuntu server and run git clone [email protected]:MyGithubRepo/service-api.git

Nate T avatar
it flag
OOOOh! I forgot. Git just redid their access restrictions agreement recently. Used to you could just let it prompt you for a password, but giving password via terminal is not allowed on github now, period. You have to set up an ssh key, even if you will only be using it once on that machine...
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.