gongxiangp2/temp-ssh-external.ps1

26 lines
767 B
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

$password = "peATjCBUn2Js"
$command = "ls -lh /app/uploads/"
# 使用plink (PuTTY的命令行版本)
# 如果没有plink,使用expect脚本
$expectScript = @"
spawn ssh -o StrictHostKeyChecking=no root@103.118.245.6 $command
expect "password:"
send "$password\r"
expect eof
"@
# 保存到临时文件
$tempExpect = Join-Path $env:TEMP "ssh-external.exp"
$expectScript | Out-File -FilePath $tempExpect -Encoding ASCII
# 通过WSL或Git Bash执行
if (Get-Command wsl -ErrorAction SilentlyContinue) {
$tempExpectWSL = $tempExpect -replace '\\', '/' -replace 'C:', '/mnt/c'
wsl expect $tempExpectWSL
} else {
Write-Host "请手动SSH到 103.118.245.6 并检查 /app/uploads/ 目录"
Write-Host "用户名: root"
Write-Host "密码: $password"
}