LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Hiding a password from process status (https://www.linuxquestions.org/questions/linux-general-1/hiding-a-password-from-process-status-4175510128/)

semple1990 07-04-2014 12:05 PM

Hiding a password from process status
 
Hi All,

Not sure if this is actually possible, or if there is a more suitable method...

I set a password for the rar command (rar a folder.rar -hpThisIsThePassword.....)

However if I search for this process, the password is displayed:

Code:

ps -ef | grep rar

30480 30418 89 18:43 pts/8    00:00:13 rar a folder.rar -hpThisIsThePassword

Obviously on a shared server this makes using the password in the first place a waste of time.

Is there another method I can use to prevent the password from showing?

Thanks in advanced.

coralfang 07-04-2014 05:42 PM

Maybe you could store the rar password in a file somewhere (assuming only your user permissions have access to it) and then run the command like so:

Code:

$ rar a folder.rar -hp`cat somefile`
Can't think of anything else. :)

${i} 07-05-2014 08:01 PM

Quote:

Originally Posted by semple1990 (Post 5198674)
Is there another method I can use to prevent the password from showing?

You could store the password in a variable and then use the variable in the command string.

Code:

read -e -s -p "pass?" mypasswd
You will be prompted to enter your string. The string will not echo as you type.

Next, run your rar command like so

Code:

rar a folder.rar -hp$mypasswd
This will also keep your password not recorded in your history file.

${i} 07-05-2014 09:03 PM

I believe coralfang's method is better than mine because the password is store in a file. My method above will hide the password but it requires interaction from you.

If you want to make a strong password for your rar archive and store it in a file, you can run this command

Code:

tr -dc [:graph:] < /dev/urandom | head -c 15 | xargs -0 > somefile
This will produce a 15 character random string of numbers, letters and symbols. You can adjust the length of the string by changing the value in red.

Next, chmod your file, like so

Code:

chmod 600 somefile
Only the owner will have read-write access to the file and blocked to everyone else.

Now you can run the command that coralfang gave you

Code:

rar a folder.rar -hp`cat somefile`


All times are GMT -5. The time now is 08:50 AM.