I have a bash script, which executes a Java file. This Java file connects to an online service, and it requires that as one of the parameters I give it my password for the service. I feel uncomfortable typing my password out in the bash file, for anybody to see. Is there any way for me to "hide" the password in the bash file, encrypt it or something?
|
Use
If the script is supposed to be public, then there is no good way to protect it – the password would still have to be decrypted before being given to the Java program, and if the script can do it, anyone can do it. If it is to be run by several users, but on a machine you control, then you can keep it protected (chmod) and configure sudo to allow running only that particular script. (For more complicated stuff, some kind of splitting into client and server could be done, but it's not necessary yet.) Beware though, that the whole command line of your Java app will be visible in |
||||
|
Instead of including the text of the password in the script, include it in another file and use I/O redirection operators or pipes to get it to the Java command. You can then assign more restrictive permissions to the file containing the password, or put it on a removeable medium, etc. |
|||
|
|
Since you mention that
to the java program is the password, you might be interested in knowing that all command-line parameters on most unix systems are published for anyone on the system to read. You might be locking the window while leaving the barn door wide open. For a demonstration, try:
You should be able to use the arrow-keys to browse to the right and see the full command-lines of all processes executing on your system. |
|||||||||||
|
