push代码会出现错误以及码云或github生成/添加SSH公钥

在没有安装ssh公钥的时候push代码会出现一下报错,是因为没有公钥导致。

$ git clone [email protected]:bayi_lzp/vue-c.git
Cloning into 'vue-cli3-init'...
The authenticity of host 'gitee.com (218.11.0.86)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitee.com,218.11.0.86' (ECDSA) to the list of known hosts.

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

1.打开命令行工具,生成 sshkey

按如下命令来生成 sshkey:

ssh-keygen -t rsa -C "[email protected]" 邮箱自定义

image.png

按照提示完成三次回车,即可生成 ssh key。通过查看 ~/.ssh/id_rsa.pub 文件内容,获取到你的 public key

2.查看 ~/.ssh/id_rsa.pub 文件内容

cat ~/.ssh/id_rsa.pub

image.png

3.复制生成后的 public key,添加到仓库中,下面以码云为例

image.png

你可能感兴趣的:(push代码会出现错误以及码云或github生成/添加SSH公钥)