Update scripts to use dynamic username instead of hardcoded alexz
Some checks failed
Test / test (push) Has been cancelled

- setup-autologin-sshd.ps1: Uses $env:USERNAME, prompts for password
- setup-ssh-keys.ps1: Uses $env:USERNAME, prompts for public key
- install-nodejs.ps1: Uses $env:USERNAME in instructions
- vpn-login.js: Uses process.env.USERPROFILE for paths

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-18 08:44:33 +00:00
parent 069ad3880f
commit 5ed8f84419
4 changed files with 34 additions and 15 deletions

View File

@@ -1,9 +1,10 @@
# Install Node.js on Windows
# Run as Administrator in PowerShell
$nodeVersion = "22.9.0"
$nodeVersion = "22.12.0"
$nodeUrl = "https://nodejs.org/dist/v$nodeVersion/node-v$nodeVersion-x64.msi"
$installerPath = "$env:TEMP\node-installer.msi"
$Username = $env:USERNAME
Write-Host "Downloading Node.js v$nodeVersion..." -ForegroundColor Cyan
Invoke-WebRequest -Uri $nodeUrl -OutFile $installerPath
@@ -25,6 +26,6 @@ Remove-Item $installerPath -Force
Write-Host ""
Write-Host "Next steps:" -ForegroundColor Yellow
Write-Host "1. Copy vpn-login.js, socks5.js, vpn.bat to C:\Users\alexz\vpn_scripts\"
Write-Host "2. Open CMD in C:\Users\alexz\vpn_scripts\ and run: npm install ws otplib"
Write-Host "1. Copy vpn-login.js, socks5.js, vpn.bat to C:\Users\$Username\vpn_scripts\"
Write-Host "2. Open CMD in C:\Users\$Username\vpn_scripts\ and run: npm install ws otplib"
Write-Host "3. Add vpn.bat shortcut to shell:startup folder"

View File

@@ -1,8 +1,15 @@
# Setup OpenSSH Server and Auto-Login for alexz
# Setup OpenSSH Server and Auto-Login
# Run as Administrator in PowerShell
$Username = "alexz"
$Password = "Az@83278327$$@@"
param(
[string]$Username = $env:USERNAME,
[string]$Password
)
if (-not $Password) {
$securePassword = Read-Host "Enter password for $Username" -AsSecureString
$Password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePassword))
}
Write-Host "=== Setting up OpenSSH Server ===" -ForegroundColor Cyan

View File

@@ -1,12 +1,23 @@
# Setup SSH Keys for alexz user
# Setup SSH Keys
# Run as Administrator in PowerShell
$PublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGHUQnw0WfeFRQx76UlImXXhu3xeOH41PmDRid8pWK1D alexz@AZawPC-P16S"
param(
[string]$Username = $env:USERNAME,
[string]$PublicKey
)
Write-Host "=== Setting up SSH Keys ===" -ForegroundColor Cyan
if (-not $PublicKey) {
# Default public key - replace with your own or pass as parameter
$PublicKey = Read-Host "Enter SSH public key (or press Enter for default)"
if (-not $PublicKey) {
$PublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGHUQnw0WfeFRQx76UlImXXhu3xeOH41PmDRid8pWK1D"
}
}
Write-Host "=== Setting up SSH Keys for $Username ===" -ForegroundColor Cyan
# User authorized_keys
$userSshDir = "C:\Users\alexz\.ssh"
$userSshDir = "C:\Users\$Username\.ssh"
$userAuthKeys = "$userSshDir\authorized_keys"
Write-Host "Creating user .ssh directory..." -ForegroundColor Yellow
@@ -16,7 +27,7 @@ Write-Host "Adding key to user authorized_keys..." -ForegroundColor Yellow
Add-Content -Path $userAuthKeys -Value $PublicKey -Force
# Fix permissions for user file
icacls $userAuthKeys /inheritance:r /grant "alexz:F" /grant "SYSTEM:F"
icacls $userAuthKeys /inheritance:r /grant "${Username}:F" /grant "SYSTEM:F"
# Administrator authorized_keys (for admin users)
$adminAuthKeys = "C:\ProgramData\ssh\administrators_authorized_keys"
@@ -28,5 +39,5 @@ Add-Content -Path $adminAuthKeys -Value $PublicKey -Force
icacls $adminAuthKeys /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"
Write-Host ""
Write-Host "SSH keys configured!" -ForegroundColor Green
Write-Host "You can now SSH in with the id_ed25519-lenovo key." -ForegroundColor Yellow
Write-Host "SSH keys configured for '$Username'!" -ForegroundColor Green
Write-Host "You can now SSH in with the corresponding private key." -ForegroundColor Yellow

View File

@@ -286,7 +286,7 @@ async function main() {
// Start SOCKS5 proxy only after VPN verified
log("Starting SOCKS5 proxy on port 1080...");
run("taskkill /F /IM node.exe /FI \"WINDOWTITLE eq socks5\"");
spawn("node", ["C:\\Users\\alexz\\vpn_scripts\\socks5.js"], {
spawn("node", ["" + process.env.USERPROFILE + "\\vpn_scripts\\socks5.js"], {
detached: true,
stdio: "ignore",
windowsHide: true
@@ -441,7 +441,7 @@ async function reconnectVpn() {
log("Reconnection successful!");
// Restart socks5
run("taskkill /F /IM node.exe /FI \"WINDOWTITLE eq socks5\"");
spawn("node", ["C:\\Users\\alexz\\vpn_scripts\\socks5.js"], {
spawn("node", ["" + process.env.USERPROFILE + "\\vpn_scripts\\socks5.js"], {
detached: true,
stdio: "ignore",
windowsHide: true