diff --git a/README.md b/README.md index 142bb8f..80a95ee 100644 --- a/README.md +++ b/README.md @@ -169,9 +169,9 @@ Flags: --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) - --timeout.command int timeout seconds for handling each target host --config string config file (default {$PWD,$HOME}/.gossh.yaml) -h, --help help for gossh diff --git a/docs/vault.md b/docs/vault.md index 360c46f..bad8df1 100644 --- a/docs/vault.md +++ b/docs/vault.md @@ -51,7 +51,7 @@ Confirm plaintext: GOSSH-AES256:349a1220bc8adbb6b784624e8f4e913b24cf0836c45b73e9ab16c66cec7c3adf ``` -### demo3 +#### demo3 ```sh $ gossh vault encrypt "the-password" -V ./vault-pass-file diff --git a/internal/cmd/command.go b/internal/cmd/command.go index 63cc1cb..d29d146 100644 --- a/internal/cmd/command.go +++ b/internal/cmd/command.go @@ -33,12 +33,15 @@ import ( var shellCommand string const commandCmdExamples = ` - # Execute command 'uptime' on target hosts. + Execute command 'uptime' on target hosts. $ gossh command host1 host2 -e "uptime" -u zhangsan -k - # Use sudo as root to execute command on target hosts. + Use sudo as root to execute command on target hosts. $ gossh command host[1-2] -e "uptime" -u zhangsan -s + Use sudo as other user 'mysql' to execute command on target hosts. + $ gossh command host[1-2] -e "uptime" -u zhangsan -s -U mysql + Find more examples at: https://github.com/windvalley/gossh/blob/main/docs/command.md` // commandCmd represents the 'command' command diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 44c20d5..8347863 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -157,13 +157,13 @@ Generate gossh configuration file. Default configuration file path: $PWD/.gossh.yaml and $HOME/.gossh.yaml, and $PWD/.gossh.yaml has higher priority than $HOME/.gossh.yaml`, Example: ` - # Generate default configuration content to screen. + Generate default configuration content to screen. $ gossh config - # Generate default configuration file. + Generate default configuration file. $ gossh config > ~/.gossh.yaml - # Generate configuration file with customized field values by specifying some global flags. + Generate configuration file with customized field values by specifying some global flags. $ gossh config -u zhangsan -c 100 -j --timeout.command 20 > ./.gossh.yaml`, Run: func(cmd *cobra.Command, args []string) { config := configflags.Config diff --git a/internal/cmd/script.go b/internal/cmd/script.go index 5dfa433..8eb4bc0 100644 --- a/internal/cmd/script.go +++ b/internal/cmd/script.go @@ -46,10 +46,10 @@ var scriptCmd = &cobra.Command{ Long: ` Execute a local shell script on target hosts.`, Example: ` - # Execute foo.sh on target hosts. + Execute foo.sh on target hosts. $ gossh script host[1-3] -e foo.sh -k - # Remove the copied 'foo.sh' on the target hosts after execution. + Remove the copied 'foo.sh' on the target hosts after execution. $ gossh script host[1-3] -i hosts.txt -e foo.sh -k -r Find more examples at: https://github.com/windvalley/gossh/blob/main/docs/script.md`, diff --git a/internal/cmd/vault/decrypt.go b/internal/cmd/vault/decrypt.go index 3ee87b9..4e76382 100644 --- a/internal/cmd/vault/decrypt.go +++ b/internal/cmd/vault/decrypt.go @@ -38,11 +38,13 @@ var decryptCmd = &cobra.Command{ Long: ` Decrypt content encrypted by vault.`, Example: ` - # Decrypt cipher text by asking for vault password. + Decrypt cipher text by asking for vault password. $ gossh vault decrypt GOSSH-AES256:a5c1b3c0cdad4669f84 - # Decrypt cipher text by vault password file or script. - $ gossh vault decrypt GOSSH-AES256:a5c1b3c0cdad4669f84 -V /path/vault-password-file-or-script`, + Decrypt cipher text by vault password file or script. + $ gossh vault decrypt GOSSH-AES256:a5c1b3c0cdad4669f84 -V /path/vault-password-file-or-script + + Find more examples at: https://github.com/windvalley/gossh/blob/main/docs/vault.md`, Args: func(cmd *cobra.Command, args []string) error { if len(args) < 1 { util.CobraCheckErrWithHelp(cmd, "requires one arg to represent the vault encrypted content") diff --git a/internal/cmd/vault/decrypt_file.go b/internal/cmd/vault/decrypt_file.go index 5173063..77722bd 100644 --- a/internal/cmd/vault/decrypt_file.go +++ b/internal/cmd/vault/decrypt_file.go @@ -43,17 +43,19 @@ var decryptFileCmd = &cobra.Command{ Long: ` Decrypt vault encrypted file.`, Example: ` - # Decrypt a vault encrypted file by asking for vault password. + Decrypt a vault encrypted file by asking for vault password. $ gossh vault decrypt-file /path/auth.txt - # Decrypt a vault encrypted file by vault password file or script. + Decrypt a vault encrypted file by vault password file or script. $ gossh vault decrypt-file /path/auth.txt -V /path/vault-password-file-or-script - # Output decrypted content to another file. + Output decrypted content to another file. $ gossh vault decrypt-file /path/auth.txt -O /path/plaintxt.txt - # Output decrypted content to screen. - $ gossh vault decrypt-file /path/auth.txt -O -`, + Output decrypted content to screen. + $ gossh vault decrypt-file /path/auth.txt -O - + + Find more examples at: https://github.com/windvalley/gossh/blob/main/docs/vault.md`, Args: func(cmd *cobra.Command, args []string) error { if len(args) < 1 { util.CobraCheckErrWithHelp(cmd, "requires one arg to represent the vault encrypted file") diff --git a/internal/cmd/vault/encrypt.go b/internal/cmd/vault/encrypt.go index 14ced3b..e8b1fe0 100644 --- a/internal/cmd/vault/encrypt.go +++ b/internal/cmd/vault/encrypt.go @@ -38,14 +38,16 @@ var encryptCmd = &cobra.Command{ Long: ` Encrypt sensitive content.`, Example: ` - # Encrypt plaintext by asking for vault password. + Encrypt plaintext by asking for vault password. $ gossh vault encrypt "your-sensitive-plaintext" - # Encrypt plaintext by vault password file or script. + Encrypt plaintext by vault password file or script. $ gossh vault encrypt "your-sensitive-plaintext" -V /path/vault-password-file-or-script - # Encrypt plaintext from terminal prompt. - $ gossh vault encrypt -V /path/vault-password-file`, + Encrypt plaintext from terminal prompt. + $ gossh vault encrypt -V /path/vault-password-file + + Find more examples at: https://github.com/windvalley/gossh/blob/main/docs/vault.md`, Args: func(cmd *cobra.Command, args []string) error { if len(args) > 1 { util.CobraCheckErrWithHelp(cmd, "to many args, only need one") diff --git a/internal/cmd/vault/encrypt_file.go b/internal/cmd/vault/encrypt_file.go index 7fbe5bb..1374302 100644 --- a/internal/cmd/vault/encrypt_file.go +++ b/internal/cmd/vault/encrypt_file.go @@ -44,17 +44,19 @@ var encryptFileCmd = &cobra.Command{ Long: ` Encrypt a file.`, Example: ` - # Encrypt a file by asking for vault password. + Encrypt a file by asking for vault password. $ gossh vault encrypt-file /path/auth.txt - # Encrypt a file by vault password file or script. + Encrypt a file by vault password file or script. $ gossh vault encrypt-file /path/auth.txt -V /path/vault-password-file-or-script - # Output encrypted content to another file. + Output encrypted content to another file. $ gossh vault encrypt-file /path/auth.txt -O /path/encryption.txt - # Output encrypted content to screen. - $ gossh vault encrypt-file /path/auth.txt -O -`, + Output encrypted content to screen. + $ gossh vault encrypt-file /path/auth.txt -O - + + Find more examples at: https://github.com/windvalley/gossh/blob/main/docs/vault.md`, Args: func(cmd *cobra.Command, args []string) error { if len(args) < 1 { util.CobraCheckErrWithHelp(cmd, "requires one arg to represent a file to be encrypted") diff --git a/internal/cmd/vault/view.go b/internal/cmd/vault/view.go index e362466..ad8c3d9 100644 --- a/internal/cmd/vault/view.go +++ b/internal/cmd/vault/view.go @@ -37,11 +37,13 @@ var viewCmd = &cobra.Command{ Long: ` View vault encrypted file.`, Example: ` - # View a vault encrypted file by asking for vault password. + View a vault encrypted file by asking for vault password. $ gossh vault view /path/auth.txt - # View a vault encrypted file by vault password file or script. - $ gossh vault view /path/auth.txt -V /path/vault-password-file-or-script`, + View a vault encrypted file by vault password file or script. + $ gossh vault view /path/auth.txt -V /path/vault-password-file-or-script + + Find more examples at: https://github.com/windvalley/gossh/blob/main/docs/vault.md`, Args: func(cmd *cobra.Command, args []string) error { if len(args) < 1 { util.CobraCheckErrWithHelp(cmd, "requires one arg to represent the vault encrypted file")