diff --git a/cmd/root.go b/cmd/root.go index bbd5324..9581e71 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -101,7 +101,11 @@ var RootCmd = &cobra.Command{ } sshUsers = append(sshUsers, sshUser{name: splits[0], password: splits[1]}) } - + if len(sshUsers) == 0 { + return fmt.Errorf(`No user specified +e.g. --user "john:mypassword" +e.g. --user "john:"`) + } // (base: https://gist.github.com/jpillora/b480fde82bff51a06238) sshConfig := &ssh.ServerConfig{ //Define a function to run when a client attempts a password login diff --git a/main/main.go b/main/main.go index 55e5f6c..6ac23fe 100644 --- a/main/main.go +++ b/main/main.go @@ -1,14 +1,12 @@ package main import ( - "fmt" "github.com/nwtgck/handy-sshd/cmd" "os" ) func main() { if err := cmd.RootCmd.Execute(); err != nil { - _, _ = fmt.Fprintf(os.Stderr, err.Error()) os.Exit(-1) } }