Last active
February 22, 2026 17:45
-
-
Save elico/6403ab1a5df4c8ca0eadfcc8d9de81d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $FunctionCode = @' | |
| function ssh-copy-id { | |
| param([Parameter(Mandatory=$true)][string]$RemoteTarget) | |
| $KeyPath = "$env:USERPROFILE\.ssh\id_ed25519.pub" | |
| if (!(Test-Path $KeyPath)) { | |
| Write-Error "Public key not found at $KeyPath" | |
| return | |
| } | |
| $PubKey = Get-Content $KeyPath | |
| ssh $RemoteTarget "mkdir -p ~/.ssh && chmod 700 ~/.ssh && echo '$PubKey' >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys" | |
| } | |
| '@ | |
| Add-Content -Path $PROFILE -Value $FunctionCode | |
| . $PROFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment