2

The openssl man page says the "-pass pass:[password]" option for the openssl command is not secure because it's visible to utilities like ps, but is it secure through bash?

Like this:

#!/bin/bash

read -s psword

openssl enc -pass pass:$psword -aes-256-cbc -in text.plaintext -out text.encrypted

I've run a program like this on my computer and all ps seems to see is "openssl". Will other utilities be able to see the password?

Otts
  • 21
  • 2

2 Answers2

1

The command line is normally easy in any operating system to get from any process normally. See this answer to getting a command line for a process. So it doesn't really matter what "starts" the process, be it bash or some custom application. This is the reason that that advise is given.

With any of these things it comes down to risk. If you accept the risk that it's not that secure then there is no reason not to use the command line (i.e. it's your machine and you are the only one using it). If lots of people can see your process sessions and possibility see a sensitive password then the risk may not be worth it. It's up to you to determine if the risk is acceptable.

Shane Powell
  • 13,698
  • 2
  • 49
  • 61
0

if you want to secure the password, then its better to write it to a file that only your process has access to, and read the password from that file in your command. This will hide the plain password in the command line and make it invisible to other processes.

You can check the following answer. It is related to generating openssl keys but is similar to this topic: How to generate an openSSL key using a passphrase from the command line?

Hichem BOUSSETTA
  • 1,791
  • 1
  • 21
  • 27