Skip to content

Commit 12ea4af

Browse files
author
qn
committedAug 18, 2015
Edit format & Add agent admitted failure
1 parent 22cc83d commit 12ea4af

File tree

1 file changed

+63
-47
lines changed

1 file changed

+63
-47
lines changed
 
+63-47
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,63 @@
1-
---
2-
layout: post
3-
title: "git ssh key"
4-
date: 2014-08-06
5-
categories: [jekyll, git]
6-
---
7-
一 设置git的user name和email:
8-
{% highlight ruby %}
9-
$ git config --global user.name "banyaner"
10-
$ git config --global user.email "1129103472@qq.com"
11-
{% endhighlight %}
12-
13-
二 生成密钥
14-
15-
ssh-keygen -t rsa -C “1129103472@qq.com
16-
17-
按3个回车,密码为空。(不要输密码)
18-
19-
然后到.ssh下面将id_rsa.pub里的内容复制出来粘贴到github个人中心的账户设置的ssh key里面
20-
三 测试
21-
{% highlight ruby %}
22-
$ ssh -T git@github.com
23-
{% endhighlight %}
24-
你将会看到:
25-
26-
{% highlight ruby %}
27-
The authenticity of host 'github.com (207.97.227.239)' can't be established.
28-
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
29-
Are you sure you want to continue connecting (yes/no)?
30-
{% endhighlight %}
31-
选择 yes
32-
如果看到Hi后面是你的用户名,就说明成功了。
33-
四 修改.git文件夹下config中的url
34-
35-
修改前
36-
{% highlight ruby %}
37-
[remote "origin"]
38-
url = https://github.com/banyaner/banyaner.github.io.git
39-
fetch = +refs/heads/*:refs/remotes/origin/*
40-
{% endhighlight %}
41-
修改后
42-
{% highlight ruby %}
43-
[remote "origin"]
44-
url = git@github.com:banyaner/banyaner.github.io.git
45-
fetch = +refs/heads/*:refs/remotes/origin/*
46-
{% endhighlight %}
47-
五 成功
1+
---
2+
layout: post
3+
title: "git ssh key"
4+
date: 2014-08-06
5+
categories: [jekyll, git]
6+
---
7+
### 一.设置git的user name和email:
8+
9+
{% highlight ruby %}
10+
$ git config --global user.name "banyaner"
11+
$ git config --global user.email "1129103472@qq.com"
12+
{% endhighlight %}
13+
14+
### 二.生成密钥
15+
16+
ssh-keygen -t rsa -C “1129103472@qq.com
17+
18+
按3个回车,密码为空。(不要输密码)
19+
20+
然后到.ssh下面将id_rsa.pub里的内容复制出来粘贴到github个人中心的账户设置的ssh key里面
21+
22+
### 三.测试
23+
24+
{% highlight ruby %}
25+
$ ssh -T git@github.com
26+
{% endhighlight %}
27+
你将会看到:
28+
29+
{% highlight ruby %}
30+
The authenticity of host 'github.com (207.97.227.239)' can't be established.
31+
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
32+
Are you sure you want to continue connecting (yes/no)?
33+
{% endhighlight %}
34+
选择 yes, 如果看到Hi后面是你的用户名,就说明成功了。
35+
36+
### 四:常见问题
37+
38+
#### 添加ssh key后始终要求输入密码
39+
40+
原因: 因为clone代码时使用https协议,而非git协议。
41+
42+
解决:
43+
44+
修改.git文件夹下config中的url
45+
46+
修改前
47+
{% highlight ruby %}
48+
[remote "origin"]
49+
url = https://github.com/banyaner/banyaner.github.io.git
50+
fetch = +refs/heads/*:refs/remotes/origin/*
51+
{% endhighlight %}
52+
修改后
53+
{% highlight ruby %}
54+
[remote "origin"]
55+
url = git@github.com:banyaner/banyaner.github.io.git
56+
fetch = +refs/heads/*:refs/remotes/origin/*
57+
{% endhighlight %}
58+
59+
#### Agent admitted failure to sign using the key
60+
61+
原因: ssh key 没有和authentication agent绑定
62+
63+
解决: 在当前用户执行`ssh-add`

0 commit comments

Comments
 (0)
Please sign in to comment.