- 场景再现:
- 此时我在新公司用 内网 IP 登录 Github,想要上传项目文件
- 输入命令:
- git init,git add .,git status,git commit -m "xx",git push -u origin master,报错
- 报错信息:
- The authenticity of host 'github.com (192.30.xxx.113)' can't be established.
- RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
- Are you sure you want to continue connecting (yes/no/[fingerprint])?
- 输入 yes 一般可以解决问题
- 如果输入回车,可能会出现报错,信息如下:
- Host key verification failed.
- fatal: Could not read from remote repository
- 表示缺少:known_host 文件(位于 .ssh 文件夹)
- 如果输入 yes 没用,可能会出现报错,信息如下:
- Warning: Permanently added 'gitee.com,192.30.xxx.113' (ECDSA) to the list of known hosts.
- Please make sure you have the correct access rights and the repository exists ...
- 表示 ssh公钥 有问题,重新生成 ssh公钥 即可
- 生成 ssh公钥 过程:
- ① 删除 .ssh(查看位置: ll -d ~/.ssh)文件夹下的 known_hosts 文件(手动删除即可)
- ② git 命令:$ ssh-****** -t rsa -C "[email protected]"
- 出现如下提示,一直 回车 就行:
- Generating public/private rsa key pair.
- Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):
- ③ 系统会在 .ssh文件夹 下生成两个文件:id_rsa 和 id_rsa.pub,用 记事本 打开 id_rsa.pub ,并复制内容
- ④ 登录自己的 Github,找到设置,将上述 复制内容 添加即可,如下:
相关文章: