diff --git a/CHANGELOG.md b/CHANGELOG.md index 98fd342..f3e6d54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.15.1] + +### Changed + +- Optimize config template and config file. +- Optimize pubkeys authentication. +- Optimize some flags description. + ## [1.15.0] ### Added diff --git a/README.md b/README.md index 244c76e..a5a433a 100644 --- a/README.md +++ b/README.md @@ -144,41 +144,41 @@ Available Commands: completion Generate the autocompletion script for the specified shell Flags: - -u, --auth.user string login user (default $USER) - -p, --auth.password string password of login user - -k, --auth.ask-pass ask for the password of login user - -a, --auth.pass-file string file that holds the password of login user - -I, --auth.identity-files strings identity files (default ~/.ssh/id_rsa) - -K, --auth.passphrase string passphrase of the identity files - -V, --auth.vault-pass-file string text file or executable file that holds the vault password - for encryption and decryption - -i, --hosts.inventory string file that holds the target hosts - -P, --hosts.port int port of the target hosts (default 22) - -l, --hosts.list outputs a list of target hosts, and does not do anything else - -s, --run.sudo use sudo to execute commands/script or fetch files/dirs - -U, --run.as-user string run via sudo as this user (default "root") - -L, --run.lang string specify i18n while executing command - (e.g. zh_CN.UTF-8|en_US.UTF-8) - -c, --run.concurrency int number of concurrent connections (default 1) - -B, --run.command-blacklist strings commands that are prohibited from execution on target hosts - (default: rm,reboot,halt,shutdown,init,mkfs,mkfs.*,umount,dd) - -o, --output.file string file to which messages are output - -j, --output.json output messages in json format - -C, --output.condense condense output and disable color - -q, --output.quiet do not output messages to screen - -v, --output.verbose show debug messages - -X, --proxy.server string proxy server address - --proxy.port int proxy server port (default 22) - --proxy.user string login user for proxy (default same as 'auth.user') - --proxy.password string password for proxy (default same as 'auth.password') - --proxy.identity-files strings identity files for proxy (default same as 'auth.identity-files') - --proxy.passphrase string passphrase of the identity files for proxy - (default same as 'auth.passphrase') - -t, --timeout.command int timeout seconds for handling each target host - --timeout.task int timeout seconds for the entire gossh task - --timeout.conn int timeout seconds for connecting each target host (default 10) - --config string config file (default {$PWD,$HOME}/.gossh.yaml) - -h, --help help for gossh + -u, --auth.user string login user (default $USER) + -p, --auth.password string password of login user + -k, --auth.ask-pass ask for the password of login user + -a, --auth.pass-file string file that holds the password of login user + -I, --auth.identity-files strings identity files (default [~/.ssh/id_rsa]) + -K, --auth.passphrase string passphrase of the identity files + -V, --auth.vault-pass-file string text file or executable file that holds the vault password + for encryption and decryption + -i, --hosts.inventory string file that holds the target hosts + -P, --hosts.port int port of the target hosts (default 22) + -l, --hosts.list outputs a list of target hosts, and does not do anything else + -s, --run.sudo use sudo to execute commands/script or fetch files/dirs + -U, --run.as-user string run via sudo as this user (default "root") + -L, --run.lang string specify i18n while executing command + (e.g. zh_CN.UTF-8|en_US.UTF-8) + -c, --run.concurrency int number of concurrent connections (default 1) + -B, --run.command-blacklist strings commands that are prohibited from execution on target hosts + (default: [rm,reboot,halt,shutdown,init,mkfs,mkfs.*,umount,dd]) + -o, --output.file string file to which messages are output + -j, --output.json output messages in json format + -C, --output.condense condense output and disable color + -q, --output.quiet do not output messages to screen + -v, --output.verbose show debug messages + -X, --proxy.server string proxy server address + --proxy.port int proxy server port (default 22) + --proxy.user string login user for proxy (default same as 'auth.user') + --proxy.password string password for proxy (default same as 'auth.password') + --proxy.identity-files strings identity files for proxy (default same as 'auth.identity-files') + --proxy.passphrase string passphrase of the identity files for proxy + (default same as 'auth.passphrase') + -t, --timeout.command int timeout seconds for handling each target host + --timeout.task int timeout seconds for the entire gossh task + --timeout.conn int timeout seconds for connecting each target host (default 10) + --config string config file (default {$PWD,$HOME}/.gossh.yaml) + -h, --help help for gossh Use "gossh [command] --help" for more information about a command. ``` diff --git a/internal/pkg/configflags/auth.go b/internal/pkg/configflags/auth.go index 40bf9e1..d3bc51f 100644 --- a/internal/pkg/configflags/auth.go +++ b/internal/pkg/configflags/auth.go @@ -53,14 +53,14 @@ type Auth struct { VaultPassFile string `json:"vault-pass-file" mapstructure:"vault-pass-file"` } -// NewAuth ... +// NewAuth config. func NewAuth() *Auth { return &Auth{ User: "", Password: "", AskPass: false, PassFile: "", - IdentityFiles: []string{}, + IdentityFiles: []string{"~/.ssh/id_rsa"}, Passphrase: "", VaultPassFile: "", } @@ -68,13 +68,13 @@ func NewAuth() *Auth { // AddFlagsTo pflagSet. func (a *Auth) AddFlagsTo(fs *pflag.FlagSet) { - fs.StringVarP(&a.User, flagAuthUser, "u", "", "login user (default $USER)") + fs.StringVarP(&a.User, flagAuthUser, "u", a.User, "login user (default $USER)") fs.StringVarP(&a.Password, flagAuthPassword, "p", a.Password, "password of login user") fs.BoolVarP(&a.AskPass, flagAuthAskPass, "k", a.AskPass, "ask for the password of login user") fs.StringVarP(&a.PassFile, flagAuthPassFile, "a", a.PassFile, `file that holds the password of login user`) - fs.StringSliceVarP(&a.IdentityFiles, flagAuthIdentityFiles, "I", nil, - "identity files (default ~/.ssh/id_rsa)") + fs.StringSliceVarP(&a.IdentityFiles, flagAuthIdentityFiles, "I", a.IdentityFiles, + "identity files") fs.StringVarP(&a.Passphrase, flagAuthPassphrase, "K", a.Passphrase, "passphrase of the identity files") fs.StringVarP(&a.VaultPassFile, flagAuthVaultPassFile, "V", a.VaultPassFile, diff --git a/internal/pkg/configflags/run.go b/internal/pkg/configflags/run.go index 49dd393..a3fc904 100644 --- a/internal/pkg/configflags/run.go +++ b/internal/pkg/configflags/run.go @@ -37,7 +37,6 @@ const ( flagRunCommandBlacklist = "run.command-blacklist" ) -// Run ... type Run struct { Sudo bool `json:"sudo" mapstructure:"sudo"` AsUser string `json:"as-user" mapstructure:"as-user"` @@ -46,7 +45,6 @@ type Run struct { CommandBlacklist []string `json:"command-blacklist" mapstructure:"command-blacklist"` } -// NewRun ... func NewRun() *Run { return &Run{ Sudo: false, @@ -55,7 +53,6 @@ func NewRun() *Run { } } -// AddFlagsTo ... func (r *Run) AddFlagsTo(flags *pflag.FlagSet) { flags.BoolVarP(&r.Sudo, flagRunSudo, "s", r.Sudo, "use sudo to execute commands/script or fetch files/dirs") flags.StringVarP(&r.AsUser, flagRunAsUser, "U", r.AsUser, "run via sudo as this user") @@ -75,11 +72,10 @@ func (r *Run) AddFlagsTo(flags *pflag.FlagSet) { "B", r.CommandBlacklist, `commands that are prohibited from execution on target hosts -(default: rm,reboot,halt,shutdown,init,mkfs,mkfs.*,umount,dd)`, +(default: [rm,reboot,halt,shutdown,init,mkfs,mkfs.*,umount,dd])`, ) } -// Complete ... func (r *Run) Complete() error { newSlice := make([]string, 0) for _, s := range r.CommandBlacklist { @@ -94,7 +90,6 @@ func (r *Run) Complete() error { return nil } -// Validate ... func (r *Run) Validate() (errs []error) { if r.Concurrency < 1 { errs = append(errs, fmt.Errorf(