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

当使用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)  # 设置为可写

  • 7
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值