简体   繁体   中英

GitHub: Permission denied (publickey). Unable to push to server

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?

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM