Skip to content

Commit 7da9b61

Browse files
committed
Fix ssh key permissions in windows
This sets correct access control for the ssh key and makes openssh on windows able to use the key without any "permission are too open error"
1 parent 7d42fed commit 7da9b61

File tree

17 files changed

+736
-0
lines changed

17 files changed

+736
-0
lines changed

Gopkg.lock

Lines changed: 131 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@
3737
[prune]
3838
go-tests = true
3939
unused-packages = true
40+
41+
[[constraint]]
42+
branch = "master"
43+
name = "github.com/hectane/go-acl"

libmachine/ssh/keys.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"runtime"
1515

1616
gossh "golang.org/x/crypto/ssh"
17+
"github.com/hectane/go-acl"
1718
)
1819

1920
var (
@@ -86,6 +87,10 @@ func (kp *KeyPair) WriteToFile(privateKeyPath string, publicKeyPath string) erro
8687
if err := f.Chmod(0600); err != nil {
8788
return err
8889
}
90+
case "windows":
91+
if err = windowsChmod(v.File, 0600); err != nil {
92+
return err
93+
}
8994
}
9095
}
9196

@@ -122,3 +127,12 @@ func GenerateSSHKey(path string) error {
122127

123128
return nil
124129
}
130+
131+
// change windows acl based permissions on file
132+
func windowsChmod(filePath string, fileMode os.FileMode) error {
133+
if err := acl.Chmod(filePath, fileMode); err != nil {
134+
return err
135+
}
136+
return nil
137+
}
138+

vendor/github.com/hectane/go-acl/LICENSE.txt

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/hectane/go-acl/README.md

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/hectane/go-acl/api/acl.go

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/hectane/go-acl/api/api.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/hectane/go-acl/api/posix.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)