不言自明。但基本上我正在尝试
shutil.rmtree
~/.ssh
并且私钥具有限制性的读/写权限。
我不想对密钥的名称做出任何假设,所以我想 chmod 777
~/.ssh
中的所有内容,然后 shutil.rmtree
它。我该怎么做?
sudo chmod -R 777 ~/.ssh
这应该可以解决问题
编辑:抱歉我没有阅读标题中的Python。我认为你可以在嵌套 for 循环中使用它。
for root, dirs, files in os.walk(ssh_dir):
for d in dirs:
os.chmod(os.path.join(root, d), 0o777)
for f in files:
os.chmod(os.path.join(root, f), 0o777)