103 Zeilen
4.4 KiB
PowerShell
103 Zeilen
4.4 KiB
PowerShell
# PowerShell script for Activity Server connection with automatic directory change
|
|
|
|
$Host.UI.RawUI.WindowTitle = "CPM Activity Server Connection"
|
|
|
|
Write-Host "================================================================================" -ForegroundColor Cyan
|
|
Write-Host " CPM Activity Server Connection" -ForegroundColor Cyan
|
|
Write-Host "================================================================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
Write-Host "Server: 91.99.192.14"
|
|
Write-Host "Username: claude-dev"
|
|
Write-Host "Target Directory: /home/claude-dev/cpm-activity-server"
|
|
Write-Host ""
|
|
|
|
# Check if plink is available
|
|
$plinkPath = Get-Command plink -ErrorAction SilentlyContinue
|
|
|
|
if ($plinkPath) {
|
|
Write-Host "Using PuTTY plink for connection..." -ForegroundColor Green
|
|
Write-Host ""
|
|
|
|
# Create a temporary expect-like script using PowerShell
|
|
Write-Host "Attempting automatic connection with directory change..." -ForegroundColor Yellow
|
|
Write-Host ""
|
|
|
|
# First attempt: Try to use plink with a command
|
|
$plinkArgs = @(
|
|
"-ssh",
|
|
"-l", "claude-dev",
|
|
"-pw", "z0E1Al}q2H?Yqd!O",
|
|
"-t",
|
|
"91.99.192.14",
|
|
"cd /home/claude-dev/cpm-activity-server && echo 'Successfully changed to Activity Server directory' && echo '' && bash -l"
|
|
)
|
|
|
|
$plinkProcess = Start-Process -FilePath "plink" -ArgumentList $plinkArgs -PassThru -Wait
|
|
|
|
if ($plinkProcess.ExitCode -ne 0) {
|
|
Write-Host ""
|
|
Write-Host "Automatic directory change failed. Starting interactive session..." -ForegroundColor Yellow
|
|
Write-Host ""
|
|
Write-Host "================================================================================" -ForegroundColor Red
|
|
Write-Host "IMPORTANT: After login, please run these commands:" -ForegroundColor Red
|
|
Write-Host ""
|
|
Write-Host " cd /home/claude-dev/cpm-activity-server" -ForegroundColor White
|
|
Write-Host " claude" -ForegroundColor White
|
|
Write-Host ""
|
|
Write-Host "================================================================================" -ForegroundColor Red
|
|
Write-Host ""
|
|
|
|
# Interactive session
|
|
& plink -ssh -l claude-dev -pw "z0E1Al}q2H?Yqd!O" -t 91.99.192.14
|
|
}
|
|
} else {
|
|
# Check for WSL
|
|
$wslPath = Get-Command wsl -ErrorAction SilentlyContinue
|
|
|
|
if ($wslPath) {
|
|
Write-Host "Using WSL for connection..." -ForegroundColor Green
|
|
Write-Host ""
|
|
|
|
# Use WSL with sshpass
|
|
$wslCommand = @"
|
|
if command -v sshpass >/dev/null 2>&1; then
|
|
echo 'Using sshpass for automatic login...'
|
|
sshpass -p 'z0E1Al}q2H?Yqd!O' ssh -o StrictHostKeyChecking=no -t claude-dev@91.99.192.14 'cd /home/claude-dev/cpm-activity-server && echo "Successfully changed to Activity Server directory" && echo && claude || bash -l'
|
|
else
|
|
echo 'Manual password entry required.'
|
|
echo 'Password: z0E1Al}q2H?Yqd!O'
|
|
echo ''
|
|
echo 'After login, run: cd /home/claude-dev/cpm-activity-server && claude'
|
|
echo ''
|
|
ssh -o StrictHostKeyChecking=no claude-dev@91.99.192.14
|
|
fi
|
|
"@
|
|
|
|
& wsl bash -c $wslCommand
|
|
} else {
|
|
# Fallback to SSH
|
|
Write-Host "No automated tools found. Using standard SSH..." -ForegroundColor Yellow
|
|
Write-Host ""
|
|
Write-Host "================================================================================" -ForegroundColor Red
|
|
Write-Host "Connection Instructions:" -ForegroundColor Red
|
|
Write-Host ""
|
|
Write-Host "1. Enter this password when prompted: z0E1Al}q2H?Yqd!O" -ForegroundColor White
|
|
Write-Host " (You can right-click to paste in most terminals)" -ForegroundColor Gray
|
|
Write-Host ""
|
|
Write-Host "2. After successful login, run these commands:" -ForegroundColor White
|
|
Write-Host " cd /home/claude-dev/cpm-activity-server" -ForegroundColor Cyan
|
|
Write-Host " claude" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
Write-Host "================================================================================" -ForegroundColor Red
|
|
Write-Host ""
|
|
Write-Host "Press any key to continue..."
|
|
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
|
|
|
& ssh claude-dev@91.99.192.14
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "Connection closed." -ForegroundColor Yellow
|
|
Write-Host "Press any key to exit..."
|
|
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") |