Skip to content

Instantly share code, notes, and snippets.

@thinkbeforecoding
Created October 10, 2016 10:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkbeforecoding/11aee0a8503b9b2450893964c45b9bc6 to your computer and use it in GitHub Desktop.
Save thinkbeforecoding/11aee0a8503b9b2450893964c45b9bc6 to your computer and use it in GitHub Desktop.
Github desktop for PS
. $env:UserProfile\AppData\Local\GitHub\shell.ps1
Function Start-SSHAgent{
param(
[Parameter(Mandatory=$false,ValueFromPipeline=$true)]
[string]$socketfile="/tmp/.ssh-socket", # Used as input to ssh-agent, which expects POSIX format paths
[Parameter(Mandatory=$false)]
[string]$pidFile="$env:TEMP\.ssh-agent-pid" # Used as input to Out-File which expects Windows format paths
)
$env:SSH_AUTH_SOCK=$socketfile
$agent_is_running = Get-Process | ? { $_.ProcessName -like "ssh-agent*"}
if($agent_is_running -eq $null){
rm $env:Temp\.ssh-socket -Force -ErrorAction SilentlyContinue
$sshAgentOutput = ssh-agent -a $env:SSH_AUTH_SOCK
$parse = Select-String -InputObject $sshAgentOutput -Pattern "(?m)SSH_AGENT_PID=(\d+)"
$sshAgentPid = $parse.Matches[0].Groups[1].Value
$sshAgentPid | Out-File $pidFile
$env:SSH_AGENT_PID = $sshAgentPid
}
}
#$r = ssh-agent -s
#[regex]::Matches($r,"SSH_AUTH_SOCK=([^;]+);") | % { $env:SSH_AUTH_SOCK = $_.Groups[1] }
#[regex]::Matches($r,"SSH_AGENT_PID=(\d+);") | % { $env:SSH_AGENT_PID = $_.Groups[1] }
Start-SSHAgent
ssh-add $env:UserProfile\.ssh\github_rsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment