1:Mac电脑生成ssh密匙

命令行输入:

ssh-keygen -t rsa -C "你的github邮箱" 

回车:

  1. Generating public/private rsa key pair.  
  2. Enter file in which to save the key (/Users/mac/.ssh/id_rsa):   
  3. Enter passphrase (empty for no passphrase):   
  4. Enter same passphrase again:   
  5. Your identification has been saved in /Users/mac/.ssh/id_rsa.  
  6. Your public key has been saved in /Users/mac/.ssh/id_rsa.pub.  
  7. The key fingerprint is:  
  8. SHA256:1vO3ou0+VwPi632vsuRxx/AE4IZfkkWM8AjtZioWqcU xxxx@gmail.com  
  9. The key's randomart image is:  
  10. +---[RSA 2048]----+  
  11. |        .....+o  |  
  12. |         ..=.+.  |  
  13. |     . . .o * o  |  
  14. |      E  .++ + . |  
  15. |     o .S++ o o .|  
  16. |    . o..  +   *.|  
  17. |     . .    = o.=|  
  18. |           ==+.+ |  
  19. |          o=*B+.o|  
  20. +----[SHA256]-----+  

---------------------------------------------

生成的ssh会保存在.ssh文件夹中(一般为隐藏文件,用户根目录下)。

打开.ssh文件夹下的id_rsa.pub这个文件,将文件中的内容复制到github  》account setting 》SSH Keys 》Add SSH Key中。

在github上新建一个文件仓库

然后xcode就可以checkout github的仓库到本地中,在本地仓库新建一个iOS项目,最后 在xcode commit -》 push就可以到github上了。

中间有需要github的仓库地址,用户密码等省略了。