简体   繁体   English

GitHub:权限被拒绝(公钥)。 无法推送到服务器

[英]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: 命令“ git remote -v”显示:

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. 我显然是GitHub的新手,对如何使用它的了解很少。 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. 我已经尝试用本地存储在笔记本电脑上的私钥以及提供给服务器和GitHub的公钥创建SSH密钥。 What am I doing wrong? 我究竟做错了什么?

It looks like you may have problem with your public key on server. 看起来您的服务器公钥可能有问题。 Try to login using ssh: 尝试使用ssh登录:

ssh -vvv root@vehiclexray.com

-vvv option prints debug messages -vvv选项打印调试消息

Your public key should be in ~/.ssh/authorized_keys file. 您的公钥应位于~/.ssh/authorized_keys文件中。 Also public key authentication must be enabled in sshd_config file: PubkeyAuthentication yes . 此外,还必须在sshd_config文件中启用公钥身份验证: PubkeyAuthentication yes After making changes into this file, you must restart ssh. 对该文件进行更改后,必须重新启动ssh。

Also choosing root as user may be not the best idea. 另外,选择root作为用户可能不是最好的主意。 Logging as root can be disabled at sshd level. 可以在sshd级别禁用以root身份登录。 You should create unprivileged user to access git repository. 您应该创建非特权用户来访问git存储库。

Another thing: it is only possible to push into bare repository. 另一件事:只能推送到裸仓库中。 You can clone bare repository with git clone --bare <repository> command. 您可以使用git clone --bare <repository>命令克隆裸仓库。

More information: Git on the Server - Setting Up the Server 详细信息: 服务器上的Git-设置服务器

Your problem has nothing with Github. 您的问题与Github无关。 You're having ssh troubles pushing to ssh://root@vehiclexray.com/ . 您在将ssh推送到ssh://root@vehiclexray.com/ The solution is the same as with GH: copy your public key to root@vehiclexray.com : 解决方案与GH相同:将您的公钥复制到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 查看git hubs帮助https://help.github.com/articles/pushing-to-a-remote#what-c​​an-i-push-to

try this 尝试这个

  1. git remote rm origin git remote rm起源
  2. git remote add origin git remote add origin
  3. git@github.com:user/repo.git git push origin master git@github.com:user / repo.git git push原始主机

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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