如果你已经安装了GitHub的windows客户端,就可以忽略此文。

1. 下载git 命令行工具 http://git-scm.com/

2.生成sshkey

2.1 cd 到保存key的文件夹

github  笔记

2.2 生成sshkey

github  笔记

出现第一个提示,

Enter file in which to save the key ,请输入将要生成的文件名

Enter passphrase (empty for no passphrase): 这个文件的密码
# Enter same passphrase again:这个文件的密码

2.3 添加到ssh-agent
github  笔记
这里要输入刚才的密码

. 错误

 解决方法:

在shell下执行  add 就好了哈。

(http://www.tangrucheng.com/implementation-of-ssh-add-could-not-open-a-connection-to-your-authentication-agent-errors.html)、

 

 github  笔记

2.4 把刚生成的文件,内容拷贝出来

 

 github  笔记

类似这种的

github  笔记

拷贝到 sshkeys里面

https://help.github.com/articles/generating-ssh-keys/

Now that you have the key copied, it's time to add it to GitHub:

  1. github  笔记In the top right corner of any page, click .

  2. github  笔记In the user settings sidebar, click SSH keys.

  3. github  笔记Click Add SSH key.

  4. In the Title field, add a descriptive label for the new key. For example, if you're using a personal Mac, you might call this key "Personal MacBook Air".
  5. github  笔记Paste your key into the "Key" field.
  6. github  笔记Click Add key.
  7. Confirm the action by entering your GitHub password.

Test everything out

To make sure everything is working, you'll now try SSHing to GitHub. When you do this, you will be asked to authenticate this action using your password, which was the passphrase you created earlier.

Open up your Git Bash and type:

ssh -T git@github.com
# Attempts to ssh to GitHub

You may see this warning:

# The authenticity of host 'github.com (207.97.227.239)' can't be established.
# RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
# Are you sure you want to continue connecting (yes/no)?

Don't worry! This is supposed to happen. Verify that the fingerprint in your terminal matches the one we've provided up above, and then type "yes."

# Hi username! You've successfully authenticated, but GitHub does not
# provide shell access.

在Git 命令行里面使用的时候,如果启用了二次验证,需要用person token代替密码使用。
否则会报错

问题解答在这里

http://stackoverflow.com/questions/17659206/git-push-authentication-failed

If you enabled two-factor authentication in your Github account you won't be able to push via HTTPS using your accounts password. Instead you need to generate a personal access token. This can be done in the application settings of your Github account. Using this token as your password should allow you to push to your remote repository via HTTPS. Use your username as usual.

Source: https://help.github.com/articles/https-cloning-errors#provide-access-token-if-2fa-enabled

Creating a token

  1. github  笔记In the top right corner of any page, click .

  2. github  笔记In the user settings sidebar, click Applications.

  3. github  笔记Click Generate new token.

  4. github  笔记Give your token a descriptive name.
  5. github  笔记Select the scopes you wish to grant to this token. The default scopes allow you to interact with public and private repositories, user data, and gists.
  6. github  笔记Click Generate token.
  7. github  笔记Copy the token to your clipboard. For security reasons, after you navigate off this page, no one will be able to see the token again.

Remember to keep your tokens secret; treat them just like passwords! They act on your behalf when interacting with the API. Don't hardcode them into your programs. Instead, opt to use them as environment variables.

When you're done using your token, feel free to click Delete to get rid of it permanently.

 

 



 

相关文章:

  • 2021-07-02
  • 2022-02-08
  • 2021-12-24
  • 2021-10-09
  • 2022-12-23
  • 2021-12-14
  • 2021-06-16
猜你喜欢
  • 2021-12-16
  • 2022-01-08
  • 2021-07-10
  • 2021-10-19
  • 2021-11-11
  • 2022-12-23
相关资源
相似解决方案