加载中…
正文 字体大小:

git push代码时提示"Permission denied (publickey)"

(2012-12-03 19:44:37)
标签:

解决方法

github

stackoverflow

permissiondenied

ssh

it

分类: 技术学习
今天想要将项目文件上传到github,结果push之后提示“Permission denied (publickey)”,如图:
git <wbr>push代码时提示"Permission <wbr>denied <wbr>(publickey)"
后来在stackoverflow上找到了解决方法:直接复制下,最后会给出原答案的链接。

Step 1: Check for SSH keys $ cd ~/.ssh # Checks to see if there is a directory named ".ssh" in your user directory # If it says "No such file or directory" skip to step 3. Otherwise continue to step 2.

Step 2: Backup and remove existing SSH keys $ ls # Lists all the subdirectories in the current directory # config id_rsa id_rsa.pub known_hosts


$ mkdir key_backup
# Makes a subdirectory called "key_backup" in the current directory

cp id_rsa* key_backup
# Copies the id_rsa keypair into key_backup

rm id_rsa*
# Deletes the id_rsa keypair

Step 3: Generate a new SSH key $ ssh-keygen -t rsa -C "your_email@youremail.com" # Creates a new ssh key using the provided email


# Generating public/private rsa key pair.
# Enter file in which to save the key (/home/you/.ssh/id_rsa):

# Enter passphrase (empty for no passphrase): [Type a passphrase]
# Enter same passphrase again: [Type passphrase again]

Your identification has been saved in /home/you/.ssh/id_rsa.
# Your public key has been saved in /home/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@youremail.com

Step 4: Add your SSH key to GitHub


$ sudo apt-get install xclip
# Downloads and installs xclip

$ xclip -sel clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard

Then, go to hithub, and do: 1. Go to your Account Settings 2. Click "SSH Keys" in the left sidebar 3. Click "Add SSH key" 4. Paste your key into the "Key" field 5. Click "Add key" 6. Confirm the action by entering your GitHub password

Step 5: Test everything out $ ssh -T git@github.com # Attempts to ssh to github

If ok, you'll see Hi username! You've successfully authenticated, but GitHub does not # provide shell access.

Otherwise (it happened with me), you will see Agent admitted failure to sign using the key. # debug1: No more authentication methods to try. # Permission denied (publickey).

To solve this


$ ssh-add
# Enter passphrase for /home/you/.ssh/id_rsa: [tippy tap]
# Identity added: /home/you/.ssh/id_rsa (/home/you/.ssh/id_rsa)



原文链接:

http://stackoverflow.com/questions/9560892/permissions-error-github-ssh-key-not-recognized

0

阅读 评论 收藏 转载 喜欢 打印举报
  • 评论加载中,请稍候...
发评论

    发评论

    以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

      

    新浪BLOG意见反馈留言板 电话:4006900000 提示音后按1键(按当地市话标准计费) 欢迎批评指正

    新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 会员注册 | 产品答疑

    新浪公司 版权所有