Ostatnio aktywny 1771689634

elicro zrewidował ten Gist 1771689634. Przejdź do rewizji

1 file changed, 16 insertions

add-ssh-copy-id.ps1(stworzono plik)

@@ -0,0 +1,16 @@
1 + $FunctionCode = @'
2 + function ssh-copy-id {
3 + param([Parameter(Mandatory=$true)][string]$RemoteTarget)
4 + $KeyPath = "$env:USERPROFILE\.ssh\id_ed25519.pub"
5 + if (!(Test-Path $KeyPath)) {
6 + Write-Error "Public key not found at $KeyPath"
7 + return
8 + }
9 + $PubKey = Get-Content $KeyPath
10 + ssh $RemoteTarget "mkdir -p ~/.ssh && chmod 700 ~/.ssh && echo '$PubKey' >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
11 + }
12 + '@
13 +
14 + Add-Content -Path $PROFILE -Value $FunctionCode
15 +
16 + . $PROFILE
Nowsze Starsze