有时候准备pull的时候却发现密码怎么输也输不对,提示的信息是没有权限或者密码错误,如下:
$ git pull
git@git.***.com's password:
Permission denied, please try again.
git@git.***.com's password:
Permission denied, please try again.
git@git.***.com's password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
如果出现以上类似的报错提示的话不妨试一下生成ssh-key的方法。步骤如下
在终端输入
ssh-keygen -t rsa -C "self name" //self name为用户名
如果执行成功。返回
Generating public/private
rsa key pair.
Enter file in which to save the key (/home/forwhat.cn/.ssh/id_rsa):
后面的几步提示都可以直接回车
$ ssh-keygen -t rsa -C "self name"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/*****/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/*****/.ssh/id_rsa.
Your public key has been saved in /c/Users/*****/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ut9Y****Wwg*******8PYsvs4v+iDlk8xXqb++YkmM self name
The key's randomart image is:
+---[RSA 2048]----+
| .o. |
| ooo |
| . *. |
|. . o o |
|... . S |
| =o. . + . |
|o.+oo . + o |
|++Eo.oo O |
|=BO+=+++=O.. |
+----[SHA2756]-----+
(敏感已处理)
把刚才上面显示的存储的地址放在vi编译器里运行会生成如下代码
vim /c/Users/*****/.ssh/id_rsa.pub(你的公钥)
//例
ssh-rsa AAAAB3NzaC1..............vvo1+xSKvIXLhjqvoHoyoj8oDkOycZeaOASJhbOT+6xvTuGutM/3SDoFkFzHjL34CnGLyX
sell name
添加已生成的秘钥 ssh-add ‘私钥Url’
ssh-add /c/Users/*****/.ssh/id_rsa
如果出现
Could not open a connection to your authentication agent.
则:
eval `ssh-agent -s`
或清空
known_hosts 文件
git config 可查看所有git配置
git config user.email 查看当前用户邮箱(查看其它以此类推)