File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,16 @@ package ssh
18
18
19
19
import (
20
20
"fmt"
21
+ "io/ioutil"
21
22
"net"
22
23
"os"
23
24
"os/exec"
24
25
"path"
25
26
"strconv"
26
27
"time"
27
28
29
+ "golang.org/x/crypto/ssh"
30
+
28
31
"github.com/docker/machine/libmachine/drivers"
29
32
"github.com/docker/machine/libmachine/engine"
30
33
"github.com/docker/machine/libmachine/log"
@@ -106,6 +109,16 @@ func (d *Driver) PreCreateCheck() error {
106
109
if _ , err := os .Stat (d .SSHKey ); os .IsNotExist (err ) {
107
110
return fmt .Errorf ("SSH key does not exist: %q" , d .SSHKey )
108
111
}
112
+
113
+ key , err := ioutil .ReadFile (d .SSHKey )
114
+ if err != nil {
115
+ return err
116
+ }
117
+
118
+ _ , err = ssh .ParsePrivateKey (key )
119
+ if err != nil {
120
+ return errors .Wrapf (err , "SSH key does not parse: %q" , d .SSHKey )
121
+ }
109
122
}
110
123
111
124
return nil
You can’t perform that action at this time.
0 commit comments