git公私钥的拷贝

1.场景

由于我换了一台电脑,为了能访问远程仓库,我就把原来电脑上的私钥和config文件拷贝过来

2.出现问题及解决方案

git clone server:xxx_service_express

报错:

    xxxdeMacBook-Pro:php root# 
    Cloning into 'xxx_service_express'...
    Bad owner or permissions on /var/root/.ssh/config
    fatal: Could not read from remote repository.

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

因为我给了config 777权限,改成600就ok了(sudo chmod 600 config),继续...

git clone server:xxx_service_express

报错:

Cloning into 'xxx_service_express'...
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for '/var/root/.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 "/var/root/.ssh/id_rsa": bad permissions
git@192.168.1.9's password:

很显然没有用到私钥嘛,让我输入密码,是给你们有一句 “Permissions 0777 for '/var/root/.ssh/id_rsa' are too open”, 私钥是只有自己访问的,也要改成600(sudo chmod 600 id_rsa), 继续...

ok

原文地址:https://www.cnblogs.com/wangweiwen/p/7216751.html