fix ssh key gen bug windows

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett 2015-04-10 10:35:25 -04:00
parent dfa155938a
commit 7f55d3ba01
No known key found for this signature in database
GPG Key ID: A519480096146526
1 changed files with 7 additions and 2 deletions

View File

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