Adds check for SSH keygen command

Adds a check to find ssh-keygen in the user's $PATH, in the event it
can't find it, return an error with a friendly message

Signed-off-by: Simon Thulbourn <simon+github@thulbourn.com>
This commit is contained in:
Simon Thulbourn 2015-01-09 23:08:52 +00:00
parent e1da47b7ca
commit ab9a19a85b
1 changed files with 4 additions and 0 deletions

View File

@ -36,6 +36,10 @@ func GetSSHCommand(host string, port int, user string, sshKey string, args ...st
} }
func GenerateSSHKey(path string) error { func GenerateSSHKey(path string) error {
if _, err := exec.LookPath("ssh-keygen"); err != nil {
return fmt.Errorf("ssh-keygen not found in the path, please install ssh-keygen")
}
if _, err := os.Stat(path); err != nil { if _, err := os.Stat(path); err != nil {
if !os.IsNotExist(err) { if !os.IsNotExist(err) {
return err return err