Merge pull request #990 from ehazlett/ssh-key-win

fix ssh key gen bug windows
This commit is contained in:
Evan Hazlett 2015-04-10 11:00:45 -04:00
commit 0c64d0538f
1 changed files with 7 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"runtime"
gossh "golang.org/x/crypto/ssh" gossh "golang.org/x/crypto/ssh"
) )
@ -79,8 +80,12 @@ func (kp *KeyPair) WriteToFile(privateKeyPath string, publicKeyPath string) erro
return ErrUnableToWriteFile return ErrUnableToWriteFile
} }
if err := f.Chmod(0600); err != nil { // windows does not support chmod
return err switch runtime.GOOS {
case "darwin", "linux":
if err := f.Chmod(0600); err != nil {
return err
}
} }
} }