github配置

来源:互联网 发布:淘宝网购物女装晚礼服 编辑:程序博客网 时间:2024/05/21 09:37
方法1. 使用git gui 直接生成
打开git gui
help – show ssh key
方法2. 使用git bash/git cmd 创建(git bash 为例 )
设置git的user.name和user.email
$ git config --global user.name "your name"$ git config --global user.email "your email"查看是否已经存在ssh key是否存在
$ cd ~/.ssh

如果没有则提示: No such file or directory
 如果有则进入~/.ssh路径下(ls查看当前路径文件,rm * 删除所有文件)生成新的ssh key

生成ssh key

cd ~ //保持在"~"目录下$ ssh-keygen -t rsa -C "xxxxxx@yy.com"//填写真实的邮箱
Generating public/private rsa key pair.Enter file in which to save the key (/c/Users/xxxx/.ssh/id_rsa):   #不填直接回车Enter passphrase (empty for no passphrase):   #输入密码(可以为空)Enter same passphrase again:   #再次确认密码(可以为空)Your identification has been saved in /c/Users/xxxx/.ssh/id_rsa.   #生成的密钥Your public key has been saved in /c/Users/xxxx/.ssh/id_rsa.pub.  #生成的公钥添加ssh key到github

打开github→Settings→SSH kyes→Add SSH key

1. 进入c:/Users/xxxx_000/.ssh/目录下,打开id_rsa.pub文件,全选复制公钥内容
2. Title自定义,将公钥粘贴到GitHub中Add an SSH key的key输入框,最后”Add Key”

测试ssh key是否设置成功

$ ssh -T git@github.com
The authenticity of host 'github.com (192.30.252.129)' can't be established.RSA key fingerprint is 16:27:xx:xx:xx:xx:xx:4d:eb:df:a6:48.Are you sure you want to continue connecting (yes/no)? yes #确认你是否继续联系,输入yesWarning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.Enter passphrase for key '/c/Users/xxxx/.ssh/id_rsa':  #生成ssh kye是密码为空则无此项,若设置有密码则有此项且,输入生成ssh key时设置的密码即可。Hi xxx! You've successfully authenticated, but GitHub does not provide shell access. #出现词句话,说明设置成功。

0 0