logo NodeSeekbeta

哪吒v1关闭ssh脚本

#!/bin/bash

# 文件路径
CONFIG_FILE="/opt/nezha/agent/config.yml"

# 检查文件是否存在
if [[ ! -f $CONFIG_FILE ]]; then
    echo "文件不存在: $CONFIG_FILE"
    exit 1
fi

# 使用 sed 修改配置文件
sed -i 's/disable_command_execute: false/disable_command_execute: true/' "$CONFIG_FILE"

# 检查是否修改成功
if grep -q "disable_command_execute: true" "$CONFIG_FILE"; then
    echo "修改成功: disable_command_execute 已设置为 true"
else
    echo "修改失败"
    exit 1
fi

# 重启 nezha-agent 服务
echo "正在重启 nezha-agent 服务..."
sudo systemctl restart nezha-agent.service

# 检查服务状态
if systemctl is-active --quiet nezha-agent.service; then
    echo "nezha-agent 服务已成功重启"
else
    echo "nezha-agent 服务重启失败,请检查日志"
    exit 1
fi

你好啊,陌生人!

我的朋友,看起来你是新来的,如果想参与到讨论中,点击下面的按钮!

📈用户数目📈

目前论坛共有71825位seeker

🎉欢迎新用户🎉