使用ssh代替https连接github

5/19/2023 #github #ssh
  1. 生成ssh key

    $ ssh-keygen 
    
  2. 添加public key到github
    Settings -> SSH and GPG keys -> New SSH key
    复制刚才生成的id_rsa.pub的内容

  3. 测试ssh连接
    如果出现Host key verification failed错误,命令行输入

    $ ssh -T [email protected]
    
  4. git config中替换掉https

    [url "[email protected]:"]
    insteadOf = https://github.com/

    或者

    git config [email protected]:.insteadOf https://github.com/