用git cmd pull 或push 时提示密码错误的解决方法

有时候准备pull的时候却发现密码怎么输也输不对,提示的信息是没有权限或者密码错误,如下

1
2
3
4
5
Warning: Permanently added the RSA host key  for IP address  '192.30.252.131' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

如果出现以上类似的报错提示的话不妨试一下生成ssh-key的方法。步骤如下
在终端输入

1
ssh-keygen -t rsa -C  "Bear Xiong" //注意。Bear Xiong为用户名

如果执行成功。返回

1
2
Generating  public / private rsa key pair.
Enter file in which to save the key (/home/forwhat.cn/.ssh/id_rsa):

后面的提示都可以直接回车

1
2
3
4
Your identification has been saved in /Users/robin/.ssh/id_rsa.
Your  public key has been saved in /Users/robin/.ssh/id_rsa.pub. //注意这一行是key存放的地址,带会会用到
The key fingerprint is:
ee:c6:b9:1b:1c:b8:7d:81:fa:32:26:ae:1c:67:99:49 Bear Xiong

再次回车。

1
2
3
4
5
6
7
8
9
10
11
12
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
|    o            |
|   + .  S        |
|  . = .  o       |
|   o + +o.o      |
|E o . o.=+.      |
|.+   ==+ooo.     |
+-----------------+

这样SSH key就生成了。

1
vi /Users/robin/.ssh/id_rsa.pub

把刚才上面显示的存储的地址放在vi编译器里运行会生成如下代码

1
2
3
4
5
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMbtcXaDkr3mHdXnwXx77sD0ssiryhr6O+Y/1awcj3JFHdZMrjQ2P5ZGX
DWGMRmLYED29PGbgJf99tG1nsy0hVkeKS4VPegIuQJKtZNe9Ila/oBHFDFTxDXzG9AEMGnxPpfLiwYeXDZDU8uSe3CiSJRz
HP3rBjsnuBSnXf431UXsYzFOBtu0DcKGR2ez41BngI+pcR8fxKoGfSUcNvrRM7Wh3nC3wZ+prwLEnVFuV4JLq/f2nrJMg2Q
FTd2xV2hpmiXMOqI0h5z/w3vOvvo1+xSKvIXLhjqvoHoyoj8oDkOycZeaOASJhbOT+6xvTuGutM/3SDoFkFzHjL34CnGLyX
  Bear Xiong


把刚才复制的贴到git的公钥那一栏里,就ok了。

本文转载至:http://blog.it985.com/2701.html

你可能感兴趣的:(工具)