标签:
如果你已经安装了GitHub的windows客户端,就可以忽略此文。
1. 下载git 命令行工具 http://git-scm.com/
2.生成sshkey
2.1 cd 到保存key的文件夹
2.2 生成sshkey
出现第一个提示,
Enter file in which to save the key ,请输入将要生成的文件名
Enter passphrase (empty for no passphrase): 这个文件的密码
# Enter same passphrase again:这个文件的密码
2.3 添加到ssh-agent
这里要输入刚才的密码
如果出现 Could not open a connection to your authentication agent. 错误
在shell下执行 $ ssh-agent bash --login -i 然后执行 $ ssh-add 就好了哈。
(http://www.tangrucheng.com/implementation-of-ssh-add-could-not-open-a-connection-to-your-authentication-agent-errors.html)、
2.4 把刚生成的文件,内容拷贝出来
类似这种的
拷贝到 sshkeys里面
https://help.github.com/articles/generating-ssh-keys/
Now that you have the key copied, it‘s time to add it to GitHub:
In the top right corner of any page, click .
In the user settings sidebar, click SSH keys.
Click Add SSH key.
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
In the top right corner of any page, click .
In the user settings sidebar, click Applications.
Click Generate new token.
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.
标签:
原文地址:http://www.cnblogs.com/xiaokang088/p/4204203.html