设置 SSH Key

  1. $ ssh-keygen -t rsa -C "邮箱地址"
回车后出现
  1. Generating public/private rsa key pair.
  2. Enter file in which to save the key (/c/Users/gs/.ssh/id_rsa):
  3. Created directory '/c/Users/gs/.ssh'.
回车后出现
  1. Enter passphrase (empty for no passphrase):
设置一个密码(输入时不会有任何字符出现)后回车
  1. Enter same passphrase again:
再次输入一次密码(输入时不会有任何字符出现)

成功后会出现类似

  1. Your identification has been saved in /c/Users/gs/.ssh/id_rsa.
  2. Your public key has been saved in /c/Users/gs/.ssh/id_rsa.pub.
  3. The key fingerprint is:
  4. fingerprnt 你的邮箱
  5. The key's randomart image is:


查看id_rsa.pub

  1. $ cat ~/.ssh/id_rsa.pub



私人密钥与GitHub进行认证通信

  1. $ ssh -T git@github.com
回车后出现
  1. The authenticity of host 'github.com (xxx.xxx.xxx.xxx)' can't be established.
  2. RSA key fingerprint is SHA256:xxxxxxxxxxxxxxx.
  3. Are you sure you want to continue connecting (yes/no)?
输入yes后回车
  1. Warning: Permanently added 'github.com,xxx.xxx.xxx.xxx' (RSA) to the list of known hosts.
  2. Enter passphrase for key '/c/Users/gs/.ssh/id_rsa':
输入之前设置的密码(输入时不会有任何字符出现)后回车
  1. Hi userid! You've successfully authenticated, but GitHub does not provide shell access.
出现上面的字符表示成功



clone已有仓库

  1. $ git clone 仓库地址

回车后弹出可能验证信息

  1. Enter passphrase for key '/c/Users/gs/.ssh/id_rsa':
需要输入一次密码
  1. remote: Counting objects: 6, done.
  2. remote: Compressing objects: 100% (4/4), done.
  3. remote: Total 6 (delta 0), reused 3 (delta 0), pack-reused 0
  4. Receiving objects: 100% (6/6), done.

表明成功。



查看状态

  1. $ git status


提交至仓库

  1. $ git add 文件名


  1. $ git commit -m "add hello world"

此时可能会弹出认证信息

  1. *** Please tell me who you are.
  2.  
  3. Run
  4.  
  5. git config --global user.email "you@example.com"
  6. git config --global user.name "Your Name"
  7.  
  8. to set your account's default identity.
  9. Omit --global to set the identity only in this repository.
这个时候就需要输入
  1. $ git config --global user.email "邮箱"
  2. $ git config --global user.name "用户名"

成功后再次输入

  1. $ git commit -m "add hello world"


  1. [master 232df5d] add hello world
  2. 1 file changed, 10 insertions(+)
  3. create mode 100644 hello_world.html

显示上面的信息表示成功提交。

这个时候可以通过

  1. $ git log
来查看日志



进行push更新仓库

  1. $ git push
进行认证后Github就能看到更新了。