最後活躍 1771689634

修訂 e6e8d4a7f03a088014052a0a6b95647563846cd6

add-ssh-copy-id.ps1 原始檔案
1$FunctionCode = @'
2function 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
14Add-Content -Path $PROFILE -Value $FunctionCode
15
16. $PROFILE