0

I am trying to clone a private repository in a vps (or droplet) with linux, I followed all the steps in the official docs and when I run the command ssh -T [email protected] I get the successful message: Hi username You've successfully authenticated, but GitHub does not provide shell access..

I also added the key to the agent with the command eval "$(ssh-agent -s)" and then ssh-add ~/.ssh/id_ed25519

But I still can't clone my private repository, when I try to run this command sudo git clone [email protected]:username/repository.git I get the following error:

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

Please make sure you have the correct access rights
and the repository exists.

Of course I replaced username and repository with my username and repository name

I don't really understand what happens, I don't know why I get a permissions denied if I get a successful connection through ssh.

9
  • 3
    Why are you using sudo? Commented Jun 8, 2024 at 3:58
  • 2
    Don't use sudo for git clone (or any git operations). Your ssh key isn't available when using sudo. If you really need to for some reason, see this: stackoverflow.com/a/73709555/5774952 Commented Jun 8, 2024 at 3:58
  • Hi, thanks for asking. If i don't use sudo i get this error: fatal: could not create work tree dir 'repository': Permission denied Commented Jun 8, 2024 at 13:51
  • 2
    Then change to a directory where your logged in user has write-access ... or, if you had previously run the same command w/ sudo in a directory where you do have write access: sudo chown -R youruser repository ... Commented Jun 8, 2024 at 21:16
  • 1
    Meta: Please summarize the comments into an answer. Commented Jun 12, 2024 at 8:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.