Initial commit
This commit is contained in:
47
scripts/ssh/enable-winrm.sh
Executable file
47
scripts/ssh/enable-winrm.sh
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
HOST="${HOST:-192.168.88.108}"
|
||||
USER_NAME="${USER_NAME:-Admin}"
|
||||
PASS="${PASS:-P@ssw0rd!}"
|
||||
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
SCRIPT="$HERE/../powershell/enable-winrm.ps1"
|
||||
LOG_DIR="$HERE/../../logs"
|
||||
STAMP="$(date +%Y%m%d-%H%M%S)"
|
||||
LOG="$LOG_DIR/enable-winrm-${HOST}-${STAMP}.log"
|
||||
|
||||
mkdir -p "$LOG_DIR"
|
||||
|
||||
SSH_OPTS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10)
|
||||
|
||||
echo "[*] Enabling WinRM on $USER_NAME@$HOST"
|
||||
echo "[*] This will configure PowerShell Remoting and WinRM service"
|
||||
echo ""
|
||||
echo "⚠️ WARNING: This script will enable Basic authentication and unencrypted"
|
||||
echo " communication for testing. Consider security implications for production."
|
||||
echo ""
|
||||
read -p "Continue? [y/N] " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Aborted."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[*] Uploading WinRM enablement script..."
|
||||
sshpass -p "$PASS" scp "${SSH_OPTS[@]}" "$SCRIPT" "$USER_NAME@$HOST:C:/Users/$USER_NAME/enable-winrm.ps1" >/dev/null
|
||||
|
||||
echo "[*] Running WinRM configuration (requires Administrator), log -> $LOG"
|
||||
echo "=================================================================="
|
||||
|
||||
sshpass -p "$PASS" ssh "${SSH_OPTS[@]}" "$USER_NAME@$HOST" \
|
||||
"powershell -NoProfile -ExecutionPolicy Bypass -File C:/Users/$USER_NAME/enable-winrm.ps1" \
|
||||
2>&1 | tee "$LOG"
|
||||
|
||||
echo "=================================================================="
|
||||
echo "[*] WinRM configuration completed. Log saved: $LOG"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Run ./check-winrm.sh to verify configuration"
|
||||
echo " 2. Test WinRM connection from this machine"
|
||||
echo " 3. If successful, update existing scripts to use WinRM"
|
||||
Reference in New Issue
Block a user