SHARE
TWEET

Untitled

a guest Oct 21st, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # ssh-id-copy for Windows. Works the same except the only supported parameter are -i and -p
  2. function Copy-SshId {
  3.     param (
  4.         [string]$destination,
  5.         [string]$i,
  6.         [string]$p
  7.     )
  8.     if ($i -eq "" -and $i -eq [String]::Empty) {
  9.         $sshdir = Get-ChildItem -Path "~/.ssh"
  10.         $pubkey = $sshdir | Where-Object { $_.extension -eq ".pub" } | Select-Object -First 1
  11.         $i = $pubkey.FullName
  12.         Write-Output "Using $i"
  13.     }
  14.     if ($p -eq "" -and $p -eq [String]::Empty) {
  15.         $p = '22'
  16.     }
  17.     $opts = @('-p', $p, $destination, '"umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys || exit 1"')
  18.     Get-Content $i | &ssh $opts
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top