git ssh 克隆的时候报权限问题

错误1: Bad owner or permissions on /root/.ssh/config

根据openssh的代码,可以看到必须是当前用户,且 当前用户组、其他用户 不能有写入权限

https://github.com/openssh/openssh-portable/blob/947a3e829a5b8832a4768fd764283709a4ca7955/readconf.c#L1709

错误2: Permission 0744 for '/root/.ssh/id_rsa' ara too open.

根据openssh的开源代码,可以看到如果当前用户组、其他用户有设置权限,都会认为是权限太高

https://github.com/openssh/openssh-portable/blob/a23698c3082ffe661abed14b020eac9b0c25eb9f/authfile.c#L104

解决方案:

# 把.ssh 下的文件设置到root用户 和 root用户组下
sudo chown root:root ~/.ssh/*
# 把 .ssh 下的文件权限设置为700,即 指定用户可以读写但不能执行,所属用户组不能读写执行,其他用户不能读写执行
sudo chmod 700 ~/.ssh/*

如果是k8s的话,需要修改storage-class,请注意 8 - 11 行

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: smartide-file-storageclass
provisioner: file.csi.azure.com # replace with "kubernetes.io/azure-file" if aks version is less than 1.21
allowVolumeExpansion: true
mountOptions:
  - dir_mode=0700
  - file_mode=0700
  - uid=0
  - gid=0
posted @ 2022-05-24 11:10  远方V3  阅读(298)  评论(0编辑  收藏  举报