您的位置:首页 > 其它

git版本管理之git-ssh 配置和使用

2016-07-29 23:33 387 查看
1.设置用户名和邮箱

$ git config --global user.name "gsx-gh"
$ git config --global user.email "gsx@126.com"


2.生成密钥

$ ssh-keygen -t rsa -C "gsx@126.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Created directory '/c/Users/Administrator/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:XwstvBad8mew3XT+IRSPV9+EZEL6WNEje+dW/qzAGFo gsx@126.com
The key's randomart image is:
+---[RSA 2048]----+
|           .+.o  |
|           ..=o. |
|          . .+..o|
|         . *..=.*|
|        S E B+ **|
|         + %.=.+=|
|        . = *.+++|
|         .   +. =|
|              ...|
+----[SHA256]-----+


3.复制/c/Users/Administrator/.ssh/id_rsa.pub中生成的内容,登陆github账号添加ssh-key







title自定义

将公钥添加到key中,点击ADD保存

4.测试

  

$ ssh -T git@github.com
The authenticity of host 'github.com (192.30.253.112)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
Hi gsx! You've successfully authenticated, but GitHub does not provide shell access.


出现以上信息,则设置成功,可以使用ssh访问提交代码。

ps:以上命令在gitbash软件命令行执行。安装git
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: