利用 Wake-on-LAN 发送 Magic packet 数据包对 PC 进行唤醒和开机;
借助 OpenSSH 服务对 PC 发送关机、休眠等指令;
以 Docker 容器的方式部署在极空间 NAS 上,并使用极空间的“远程访问”功能来实现远程控制。
Get started with OpenSSH for Windows | Microsoft Learn
# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
# Start the sshd service
Start-Service sshd
# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'
# Confirm the Firewall rule is configured. It should be created automatically by setup. Run the following to verify
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
} else {
Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
}
参考教程:[Notebook/AIO] 如何启用网络唤醒功能(Wake on LAN, WOL) | 官方支持 | ASUS 中国
管理员权限打开 Powershell 终端
# 查看网卡设备
powercfg -devicequery wake_armed
# 设置网卡设备
powercfg -deviceenablewake “Device name”
自行构建 Docker 镜像上传极空间
构建镜像
$ docker buildx build --platform="linux/arm64" -t zhiweio/my-wins-turn:latest .
导出镜像包
$ docker save zhiweio/my-wins-turn:latest -o my-wins-turn.tar
项目地址:https://github.com/zhiweio/my-wins-turn