1 Star 0 Fork 0

坐公交也用券/SSH守护

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
clean.py 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
#! /usr/bin/python3
# Author: <NAME>
# Date: 2025年3月10日09:25:03
# Description: 清除系统自带OpenSSH及备份文件
import os
import sys
class Clean:
def __init__(self):
self.p = "/usr/local/.ssh"
self.src = "/etc/ssh"
def uninstall(self):
if not os.path.isdir(self.src):
os.mkdir(self.src)
if os.system("apt-get purge openssh-server -y") != 0:
print("卸载openssh-server失败")
sys.exit(1)
def rm(self):
if os.system("rm -rf %s" % self.p) != 0:
print("删除%s失败" % self.p)
# os.system("rm -rf /etc/ssh-guardian/config.toml")
os.system("rm -rf /etc/ssh")
def install(self):
if os.system("apt-get install openssh-server -y") != 0:
print("安装openssh-server失败")
def run(self):
if os.system("go build") != 0:
print("编译ssh-guardian失败")
os.system("./ssh-guardian -debug -sec 1 -china")
def start(self):
self.uninstall()
self.rm()
self.install()
self.run()
if __name__ == "__main__":
c = Clean()
c.start()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/liumou_site/ssh-guardian.git
git@gitee.com:liumou_site/ssh-guardian.git
liumou_site
ssh-guardian
SSH守护
master

搜索帮助