Last active
September 14, 2020 02:02
-
-
Save conradakunga/7a20df44075066f8a9053a5dc91af44f to your computer and use it in GitHub Desktop.
Copy SSH Key From Windows 10
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 ssh-copy-id([string]$userAtMachine, [string]$port = 22) { | |
# Get the generated public key | |
$key = "$ENV:USERPROFILE" + "/.ssh/id_rsa.pub" | |
# Verify that it exists | |
if (!(Test-Path "$key")) { | |
# Alert user | |
Write-Error "ERROR: '$key' does not exist!" | |
} | |
else { | |
# Copy the public key across | |
& cat "$key" | ssh $userAtMachine -p $port "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment