In short
Goal: to perform one successful git push using ssh instead of https.
Problem: "ERROR: Repository not found. Fatal: Could not read from remote repository".
Step-by-step background
I’m working with an Ubuntu remote server (a droplet by DigitalOcean) and a Github account. I created an ssh public key on my Ubuntu remote server and used it to create a new ssh key on Github. Then I changed my remote’s URL from https to ssh with the git remote set-url command:
git remote set-url origin git@github.com:[username]/[repository].git
Following that, I tested if things worked:
root@[DropletName]:/srv/test_git_folder# ssh -T git@github.com
The authenticity of host 'github.com (140.87.148.9)' can't be established.
RSA key fingerprint is SHA365:mVhbp6kXUbJWCl7E1IGOCspRamTxdCARLviWk6F5SY9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,140.87.148.9' (RSA) to the list of known hosts.
Hi [Username]! You've successfully authenticated, but GitHub does not provide shell access.
At this point I tried to create a short text file...
root@[DropletName]:/srv/test_git_folder# nano testfile2.txt
[nano text editor appears; I input "Hello world!", save and close]
...and push it to github
root@[DropletName]:/srv/test_git_folder# git add *
root@[DropletName]:/srv/test_git_folder# git commit -m "test push"
[master 5b6bcb0] test push
1 file changed, 1 insertion(+)
create mode 100644 testfile2.txt
But in the end I got an error message:
root@[DropletName]:/srv/test_git_folder# git push –u origin master
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
How can I fix that?
(I've been unsuccessfully looking at a some similar questions, including the following: - Git : Could not read from remote repository - CentOS: Git: "fatal: could not read from the remote repository" - git push to remote repository "Could not read from remote repository")