后台保活

1.0.0

通过 SSH localhost 让 sshd(Session 0 的 SYSTEM 服务)以当前用户身份创建进程,
再用 WMI Win32_Process.Create 绕过 sshd 的 Job Object 使进程独立存活。
进程运行在 Session 0,远程桌面登出后不会被终止。

原理:
1. SSH 连接 localhost → sshd 运行在 Session 0,故 SSH 会话继承 Session 0
2. SSH 会话内通过 WMI 创建进程 → 进程由 wmiprvse.exe 派生,脱离 sshd Job Object
3. SSH 断开后 WMI 创建的进程不受影响,持续运行在 Session 0

首次使用自动生成 SSH 密钥并配置免密登录。
若 sshd 未启动/被禁用则通过 UAC 请求一次性
通过 SSH localhost 让 sshd(Session 0 的 SYSTEM 服务)以当前用户身份创建进程,
再用 WMI Win32_Process.Create 绕过 sshd 的 Job Object 使进程独立存活。
进程运行在 Session 0,远程桌面登出后不会被终止。

原理:
1. SSH 连接 localhost → sshd 运行在 Session 0,故 SSH 会话继承 Session 0
2. SSH 会话内通过 WMI 创建进程 → 进程由 wmiprvse.exe 派生,脱离 sshd Job Object
3. SSH 断开后 WMI 创建的进程不受影响,持续运行在 Session 0

首次使用自动生成 SSH 密钥并配置免密登录。
若 sshd 未启动/被禁用则通过 UAC 请求一次性提权。
sshd 未安装时报错提示安装命令。

前置条件:
- Windows 10 / Server 2019 或更高版本
- OpenSSH 客户端(系统内置)
- OpenSSH Server(可选功能,首次使用会提示安装)
Show more

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Script -Name 后台保活

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Copyright

(c) 2026 埃博拉酱-机器人. MIT License.

Package Details

Author(s)

  • 埃博拉酱-机器人

Tags

Session0 Background Process Persist Logoff RDP SSH WMI Windows

Dependencies

This script has no dependencies.

Release Notes

1.0.0 - 初始版本。通过 SSH localhost + WMI 在 Session 0 创建保活进程。

FileList

Version History

Version Downloads Last updated
1.0.0 (current version) 3 4/2/2026