In Ubuntu 16.04, journal logs every sudo command and some includes sensitive arguments (e.g., clear-text password) which I don't want to leave in the log. I have some idea of how to prevent that, but I would like to know if any formal way of doing it, which ideally should be simple and general enough.For example, a command like below.$ sudo set_account.sh --password SbdLb9W --pin-number 1234 --other-optionsThe journal log may render like this.sudo set_account.sh --password ... --pin-number ... --other-optionsThanks.Thanks everyone for very useful answers and comments. I think I would proceed with the approach of environment variable plus wrapper script.
How to prevent sensitive CLI arguments being logged in journalctl while using sudo?
command line;security;sudo;logs
Don't put passwords in command options.The correct way would be to use environment variables, like$ MY_PASSWORD=s3cr3t ./mycommandHowever, mycommand would need to know to look in the environment for the passwordThe password would appear in YOUR shell history, but would not be visible to other users: https://security.stackexchange.com/questions/138071/are-environment-variables-entered-directly-before-a-command-visible-to-other-If you don't want it in your shell history, put the above command in a script and run that scriptIf mycommand calls other processes, be careful not to pass MY_PASSWORD to the child processes