Created
February 7, 2021 10:57
-
-
Save pirafrank/883679626b42926bfc16aa7acc2b7fab to your computer and use it in GitHub Desktop.
ssh-copy-id as Windows PowerShell script. Put it in a folder in your PATH
This file contains 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
function print($str) { | |
Write-Host "$str" | |
} | |
if ( $($args.Count) -ne 2 -And $($args.Count) -ne 3 ) { | |
$scriptName = $MyInvocation.MyCommand.Name | |
print("Usage: .\$scriptName [args...] pubKeyFile user@host") | |
exit | |
} | |
$sshargs="" | |
$sshPubKey=$args[0] | |
$remoteHost=$args[1] | |
if ( $($args.Count) -eq 3 ) { | |
$sshargs=$args[0] | |
$sshPubKey=$args[1] | |
$remoteHost=$args[2] | |
} | |
type $env:USERPROFILE\.ssh\$sshPubKey | ssh "$sshargs" "$remoteHost" "cat >> .ssh/authorized_keys" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment