GIT推送:权限被拒绝(公钥) [英] GIT push: permission denied (public key)

查看:1235
本文介绍了GIT推送:权限被拒绝(公钥)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GIT:我试图将文件推送到朋友的回购站,但是出现公钥错误。

GIT: I'm trying to push a file to a repo of a friend but errors on public key.

git push origin testbranch
Permission denied (publickey).
fatal: Could not read from remote repository.

我们在哪里以及如何定义公钥/私钥?

Where and how do we define public / private keys?

git remote -v返回:

git remote -v returns:

origin  git@github.com:Sesamzaad/NET.git (fetch)
origin  git@github.com:Sesamzaad/NET.git (push)

提供任何帮助。

推荐答案

我面临同样的问题,这就是我所做的为我工作。

I was facing same problem, here is what I did that worked for me.

使用ssh而不是http。如果它的http为移除原始地址

Use ssh instead of http. Remove origin if its http.

git remote rm origin

添加ssh url

git remote add origin git@github.com:<username>/<repo>.git

在.ssh /文件夹中生成ssh密钥。它会询问路径和密码,您只需按回车并继续。

Generate ssh key inside .ssh/ folder. It will ask for path and passphrase where you can just press enter and proceed.

cd ~/.ssh
ssh-keygen

复制密钥。您可以使用查看您的密钥。如果您没有指定不同的路径,那么这是默认路径。

Copy the key. You can view your key using. If you hadn't specified a different path then this is the default one.

cat ~/.ssh/id_rsa.pub

将此密钥添加到您的github帐户。下一步

Add this key to your github account. Next do

ssh -T git@github.com

您将在控制台中收到一条欢迎消息。

You will get a welcome message in your console.

cd到您的项目文件夹。 git push -u origin master 现在可以工作了!

cd into to your project folder. git push -u origin master now works!

这篇关于GIT推送:权限被拒绝(公钥)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆