0

I am getting the error:

VehicleXray git:(master) ✗ git push live master
Permission denied (publickey).
fatal: Could not read from remote repository.

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

The command "git remote -v" shows:

live    ssh://root@vehiclexray.com/var/repo/VehicleXray.git (fetch)
live    ssh://root@vehiclexray.com/var/repo/VehicleXray.git (push)
origin  https://github.com/enayet123/VehicleXray.git (fetch)
origin  https://github.com/enayet123/VehicleXray.git (push)

I am clearly new to GitHub and minimal understanding on how to use it. I have already attempted to create a SSH key with the private key stored locally on my laptop and the public keys given to both my server and GitHub. What am I doing wrong?

Enayet Hussain
  • 908
  • 4
  • 17
  • 33

4 Answers4

1

It looks like you may have problem with your public key on server. Try to login using ssh:

ssh -vvv root@vehiclexray.com

-vvv option prints debug messages

Your public key should be in ~/.ssh/authorized_keys file. Also public key authentication must be enabled in sshd_config file: PubkeyAuthentication yes. After making changes into this file, you must restart ssh.

Also choosing root as user may be not the best idea. Logging as root can be disabled at sshd level. You should create unprivileged user to access git repository.

Another thing: it is only possible to push into bare repository. You can clone bare repository with git clone --bare <repository> command.

More information: Git on the Server - Setting Up the Server

Michał Pipa
  • 562
  • 3
  • 10
1

Your problem has nothing with Github. You're having ssh troubles pushing to ssh://root@vehiclexray.com/. The solution is the same as with GH: copy your public key to root@vehiclexray.com:

ssh-copy-id root@vehiclexray.com
phd
  • 82,685
  • 13
  • 120
  • 165
0

check out git hubs help https://help.github.com/articles/pushing-to-a-remote#what-can-i-push-to

try this

  1. git remote rm origin
  2. git remote add origin
  3. git@github.com:user/repo.git git push origin master
  • My issue isn't with pushing to GitHub itself. I'm trying to push to my server of which has the remote called "live" – Enayet Hussain Jul 13 '17 at 11:42
  • Have you tried looking at this? https://stackoverflow.com/questions/3728054/git-push-to-live-server –  Jul 13 '17 at 11:53
0

This worked for me:

Step 1 - git remote rm origin
Step 2 - select the http option in github
step 3 - run the following command again

git remote add origin https://github.com/yourdirectory/link.git  
git branch -M main  
git push -u origin main  
Obsidian
  • 3,719
  • 8
  • 17
  • 30