Git 如何使用ssh上传或者同步/下载项目到github

前言

  使用github上传托管自己的一些工具代码是作为一个程序员必备技能.下面就说明如何github使用ssh方式免密码同步方式

客户端产生公私钥

ssh-kengen -t rsa -C “some comments”,之后有三次询问,直接回车
如果是cygwin客户端,需要创建/home/user目录

添加公钥到github账户

  1. 使用网页登陆github,在settings–>ssh keys–>add key
  2. cat /home/user/.ssh/id_rsa.pub,把内容粘贴到网页上

测试账号登陆

ssh [email protected]
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 [email protected]:username/projectname.git

git设置默认用户名

$ git config --global user.name "username"
$ git config --global user.email "address@mail"

猜你喜欢

转载自www.cnblogs.com/guanxinjing/p/11505193.html