Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

2023-12-20 16:44:21

当使用ssh登录服务器时,由于文件权限没有设置报以下错误

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions for 'test_1.pem' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. Load key "test_1.pem": bad permissions ec2-user@ec2-52-83-237-4.cn-northwest-1.compute.amazonaws.com.cn: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Linux可直接使用chmod设置权限

chmod 600 filename

window可以通过有点属性里设置文件权限,也可以通过python代码设置

import os
import stat

def set_read_only(file_path):
    # 设置文件为只读
    os.chmod(file_path, stat.S_IREAD)

def set_writeable(file_path):
    # 设置文件为可写
    os.chmod(file_path, stat.S_IWRITE)

file_path = 'path/to/your/file.txt'
set_read_only(file_path)  # 设置为只读
# set_writeable(file_path)  # 设置为可写

文章来源:https://blog.csdn.net/weixin_53704902/article/details/135108793
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。