Skip to content

Streamlined GPG/SSH workflow #3

@andrejusk

Description

@andrejusk

Current drafts:

# Export GPG (A) key as SSH
if (!$env:USER_EMAIL) { Write-Error "`$env:USER_EMAIL not set"; return "" }
else {
    gpg --export-ssh-key $env:USER_EMAIL > $home/.ssh/authorized_keys
}

# Schedule gpg-connect-agent to run on login
# https://www.kaylyn.ink/journal/windows-using-gpg-for-ssh-authentication-and-git/
$job = Register-ScheduledJob `
	-Name GpgAgent `
	-ScriptBlock { gpg-connect-agent.exe /bye } `
	-Trigger (New-JobTrigger -AtLogOn -User $(`
        [System.Security.Principal.WindowsIdentity]::GetCurrent().Name) `
    ) `
	-ScheduledJobOption (New-ScheduledJobOption -StartIfOnBattery -ContinueIfGoingOnBattery) `
	-RunNow

# Change principal to run only on interactive logon instead of S4A.
$principal = New-ScheduledTaskPrincipal -LogonType Interactive -UserId $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)
Set-ScheduledTask -TaskPath \Microsoft\Windows\PowerShell\ScheduledJobs\ -TaskName $job.Name -Principal $principal

# Remove-FromPath "$env:SYSTEMROOT\System32\OpenSSH\"

# $tempPath = curlex `
# 	"https://github.com/benpye/wsl-ssh-pageant/releases/download/20200408.1/wsl-ssh-pageant-amd64.exe"

# # Ensure dst exists
# New-Item "$HOME/bin" -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null

# Move-Item -Path $tempPath -Destination "$HOME/bin/wsl-ssh-pageant.exe"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions