Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ssh-copy-id for powershell.
- #
- function ssh-copy-id() {
- [CmdletBinding(DefaultParameterSetName='userAtMachine')]
- Param(
- [parameter(Mandatory=$false)]
- [String]
- $i,
- [parameter(Mandatory=$true, ValueFromRemainingArguments=$true, ParameterSetName='userAtMachine')]
- [String]
- $userAtMachine
- )
- if (!$i) {
- $publicKey = "$ENV:USERPROFILE" + "/.ssh/id_ed25519.pub"
- } else {
- $publicKey = $i
- }
- Write-Host $publicKey
- if (!(Test-Path "$publicKey")){
- Write-Error "ERROR: failed to open ID file '$publicKey': No such file"
- }
- else {
- & cat "$publicKey" | ssh $userAtMachine "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement