Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement