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.
sudo?sudoforgit clone(or any git operations). Your ssh key isn't available when usingsudo. If you really need to for some reason, see this: stackoverflow.com/a/73709555/5774952fatal: could not create work tree dir 'repository': Permission deniedsudo chown -R youruser repository...