How to hide passwords in a shell script?

How to hide passwords in a shell script?

There are however other things you can do to prevent such glancing of username and/or passwords. Obfuscating : If you don’t want anyone to read the username or password while you edit a script you can put it in the text but not as plain text, but obfuscated.

Is there a way to not have a password in a script?

First of all, if there is any way at all you can change things to avoid having to store a password inside or alongside a script in the first place, you should make every effort to do that. Jenny D’s answer contains a lot of good advice to that effect.

What happens if you use a hard coded password?

Knowledge of the product or access to code. The use of a hard-coded password has many negative implications – the most significant of these being a failure of authentication measures under certain circumstances.

Is there a way to store passwords in a bash script?

There’s a way to store passwords in a bash script but you have to encrypt and obfuscate the script so that no one can actually read it or run any type of debugger on it to see exactly what it is doing. To encrypt and obfuscate a bash/shell script and have it actually be executable, try copying and pasting it here:

How to protect shell script’s code stack overflow?

You just need to know what goes into the program and what goes in the script. Make the script readable only by some specified account, and provide an executable, setuid to that account, that runs the script. Of course that means the script will run with the specified account’s privileges rather than the user’s privileges.

How to hide user input in Linux script?

\\b \\b is needed to give the appearance of deleting the character to the left; just using \\b moves the cursor to the left, but leaves the character intact ( nondestructive backspace). By printing a space and moving back again, the character appears to have been erased (thanks, The “backspace” escape character ‘\\b’ in C, unexpected behavior?

Is there any way to hide the secret from the command line?

While running the command I can read through ps -ef | grep command-name which is the secret. Is there any way of hiding the secret in a way that through ps -ef, the command line parameter is obfuscated? First, you can NOT hide command line arguments.

How does Sudo read the password from the standard input?

The -S flag makes sudo read the password from the standard input. As explained in man sudo: Write the prompt to the standard error and read the password from the standard input instead of using the terminal device. The password must be followed by a newline character. So, to run ls with sudo privileges, you would do

How can I run LS with sudo privileges?

Write the prompt to the standard error and read the password from the standard input instead of using the terminal device. The password must be followed by a newline character. So, to run ls with sudo privileges, you would do

Is it OK to hide a password in a file?

Your idea of hiding the password in an inaccessible place might be OK depending on the circumstances. If the information is separate, that means simple editing of the file, e.g. during a code review with a colleague is not going to show it. But realise anyone with access to your account can easily find such a file.