$port = Read-Host "输入 frpc 端口(已用: 12022=天翼云, 12023=移动云, 下一个填 12024)" $base = "https://scripts.cong.in/packages" Write-Host "下载安装包..." (New-Object System.Net.WebClient).DownloadFile("$base/openssh.zip", "C:\openssh.zip") (New-Object System.Net.WebClient).DownloadFile("$base/frp-win.zip", "C:\frp.zip") Write-Host "安装 OpenSSH..." Expand-Archive -Path "C:\openssh.zip" -DestinationPath "C:\OpenSSH" -Force Set-ExecutionPolicy Bypass -Scope Process -Force & "C:\OpenSSH\OpenSSH-Win64\install-sshd.ps1" sc.exe config sshd obj= "LocalSystem" | Out-Null Set-Service sshd -StartupType Automatic Start-Service sshd Write-Host "配置 frpc..." Expand-Archive -Path "C:\frp.zip" -DestinationPath "C:\frp" -Force $frpDir = "C:\frp\frp_0.61.1_windows_amd64" $cfgPath = "$frpDir\frpc.toml" $lines = @( "serverAddr = `"5.181.219.106`"", "serverPort = 7000", "auth.token = `"tianyiyun2026`"", "", "[[proxies]]", "name = `"cloudpc-ssh`"", "type = `"tcp`"", "localIP = `"127.0.0.1`"", "localPort = 22", "remotePort = $port" ) [System.IO.File]::WriteAllLines($cfgPath, $lines) Unregister-ScheduledTask -TaskName frpc -Confirm:$false 2>$null $action = New-ScheduledTaskAction -Execute "$frpDir\frpc.exe" -Argument "-c $cfgPath" $trigger = New-ScheduledTaskTrigger -AtStartup $principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest Register-ScheduledTask -TaskName frpc -Action $action -Trigger $trigger -Principal $principal -Force | Out-Null Start-ScheduledTask -TaskName frpc Write-Host "配置 SSH 免密登录..." New-Item -ItemType Directory -Force "C:\ProgramData\ssh" | Out-Null $pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPesNV2GPaFs1abSBHySXYfUb4ExsiNpokCZ2DXh43O9 root@cong.in" Set-Content "C:\ProgramData\ssh\administrators_authorized_keys" $pubkey -Encoding UTF8 icacls "C:\ProgramData\ssh\administrators_authorized_keys" /inheritance:r /grant "SYSTEM:F" /grant "Administrators:F" | Out-Null Write-Host "完成!frpc 端口: $port,SSH 免密登录已配置"