this repo has no description
dotfiles

Do not launch ssh-agent on Windows anymore

+16 -16
+16 -16
windows/ssh-agent-utils.ps1
··· 20 20 if ([int]$agentPid -eq 0) { 21 21 $agentPid = [Environment]::GetEnvironmentVariable("SSH_AGENT_PID", "Process") 22 22 } 23 - 23 + 24 24 if ([int]$agentPid -eq 0) { 25 25 0 26 26 } else { 27 27 # Make sure the process is actually running 28 28 $process = Get-Process -Id $agentPid -ErrorAction SilentlyContinue 29 - 29 + 30 30 if(($process -eq $null) -or ($process.ProcessName -ne "ssh-agent")) { 31 31 # It is not running (this is an error). Remove env vars and return 0 for no agent. 32 32 [Environment]::SetEnvironmentVariable("SSH_AGENT_PID", $null, "Process") ··· 45 45 function Start-SshAgent() { 46 46 # Start the agent and gather its feedback info 47 47 [string]$output = ssh-agent 48 - 48 + 49 49 $lines = $output.Split(";") 50 50 $agentPid = 0 51 - 51 + 52 52 foreach ($line in $lines) { 53 53 if (([string]$line).Trim() -match "(.+)=(.*)") { 54 - # Set environment variables for user and current process. 54 + # Set environment variables for user and current process. 55 55 [Environment]::SetEnvironmentVariable($matches[1], $matches[2], "Process") 56 56 [Environment]::SetEnvironmentVariable($matches[1], $matches[2], "User") 57 - 57 + 58 58 if ($matches[1] -eq "SSH_AGENT_PID") { 59 59 $agentPid = $matches[2] 60 60 } 61 61 } 62 62 } 63 - 63 + 64 64 # Show the agent's PID as expected. 65 65 Write-Host "SSH agent PID:", $agentPid 66 66 } ··· 74 74 if ($proc -ne $null) { 75 75 Stop-Process $agentPid 76 76 } 77 - 77 + 78 78 # Remove all enviroment variables 79 79 [Environment]::SetEnvironmentVariable("SSH_AGENT_PID", $null, "Process") 80 80 [Environment]::SetEnvironmentVariable("SSH_AGENT_PID", $null, "User") ··· 96 96 } 97 97 98 98 # Start the agent if not already running; provide feedback 99 - $agent = Get-SshAgent 100 - if ($agent -eq 0) { 101 - Write-Host "Starting SSH agent..." 102 - Start-SshAgent # Start agent 103 - Add-SshKey # Add my default key 104 - } else { 105 - Write-Host "SSH agent is running (PID $agent)" 106 - } 99 + #$agent = Get-SshAgent 100 + #if ($agent -eq 0) { 101 + # Write-Host "Starting SSH agent..." 102 + # Start-SshAgent # Start agent 103 + # Add-SshKey # Add my default key 104 + #} else { 105 + # Write-Host "SSH agent is running (PID $agent)" 106 + #}