github使用ssh方式免密码同步方式
github可以支持ssh公私钥登陆 , 当同步公钥到github后,可以方便的同步而不用输入密码。
客户端产生公私钥
- ssh-kengen -t rsa -C “some comments”,之后有三次询问,直接回车
如果是cygwin客户端,需要创建/home/user目录
添加公钥到github账户
- 使用网页登陆github,在settings–>ssh keys–>add key
- cat /home/user/.ssh/id_rsa.pub,把内容粘贴到网页上
测试账号登陆
ssh git@github.com
The authenticity of host 'github.com (192.30.252.131)' 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)? yes
Warning: Permanently added 'github.com,192.30.252.131' (RSA) to the list of known hosts.
PTY allocation request failed on channel 0
Hi robinchenyu! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
客户端的下载的仓库应选用ssh方式
git clone git@github.com:username/projectname.git
git设置默认用户名
$ git config --global user.name "username"
$ git config --global user.email "address@mail"