将旧电脑上的 known_hosts、id_rsa、id_rsa.pub 这三个文件直接拷贝到新电脑的 .ssh 文件目录下拉取代码出现了一个报错信息:
Permissions 0644 for '/Users/apple/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/Users/apple/.ssh/id_rsa": bad permissions
git@codeup.aliyun.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
这个报错的意思大概就是说,id_rsa
文件的权限太高了,需要降级文件权限,于是解决方案也非常简单:
将 id_rsa 降级为 0600 就可以了
chmod 0600 ~/.ssh/id_rsa