linux 上建立ssh key,添加到ssh-agent

使用github时,遇到问题:

Permission denied (publickey).

fatal: Could not read from remote repository.

解决办法:

1 打开命令行,执行如下命令:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

此命令会生成两个文件,id_rsa,和id_rsa.pub.

当提示"Enter a file in which to save the key," 时,按回车,将生成的文件存储到默认位置,然后再根据提示按两次回车

2 执行如下命令,打开ssh-agent

eval "$(ssh-agent -s)"

Add your SSH private key to the ssh-agent. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_rsa in the command with the name of your private key file.

3 执行如下命令,将ssh key 添加到ssh-agent:

ssh-add ~/.ssh/id_rsa

4 将我们生成的key添加到github 账户中,添加办法:点这里.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容