package sshkey import ( "bytes" "errors" "os/exec" ) const skgpath = "/usr/bin/ssh-keygen" func ValidKey(key string) (valid bool, err error) { cmd := exec.Command(skgpath, "-l", "-f", "-") cmd.Stdin = bytes.NewBuffer([]byte(key)) err = cmd.Run() if err == nil { valid = true } else if errors.Is(&exec.ExitError{}, err) { err = nil } return }