Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ssh-id-copy for Windows. Works the same except the only supported parameter are -i and -p
- function Copy-SshId {
- param (
- [string]$destination,
- [string]$i,
- [string]$p
- )
- if ($i -eq "" -and $i -eq [String]::Empty) {
- $sshdir = Get-ChildItem -Path "~/.ssh"
- $pubkey = $sshdir | Where-Object { $_.extension -eq ".pub" } | Select-Object -First 1
- $i = $pubkey.FullName
- Write-Output "Using $i"
- }
- if ($p -eq "" -and $p -eq [String]::Empty) {
- $p = '22'
- }
- $opts = @('-p', $p, $destination, '"umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys || exit 1"')
- Get-Content $i | &ssh $opts
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement