Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ssh-copy-id as Windows PowerShell script. Put it in a folder in your PATH
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")
if ( $($args.Count) -eq 3 ) {
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