Ray
Ray

Reputation: 2258

Hide a password on argv from ps or who

So I'm working to hide the password from the ps -aux list, or w list in linux.

I'm using rlwrap and sqlplus, connecting thusly:

rlwrap sqlplus user/pass@connect_identifier

And it shows my pass in plaintext in the who list.

Anyone know how I can make it so that it does not show the password?

Upvotes: 1

Views: 1713

Answers (2)

mark4o
mark4o

Reputation: 60993

It is best to prompt for a password, read it from stdin or a file, or get it from an environment variable. However if you really want to change what is shown by ps you can use a function commonly called setproctitle(). On some BSD systems this is in the C library, but there are various other implementations. Of course, if you do this then there is still a brief period where another user could see the original arguments before you change them.

Upvotes: 1

DaveR
DaveR

Reputation: 9640

(Answer shamelessly stolen from here)

You can invoke sqlplus with something like:

rlwrap sqlplus internal @/path/to/script

where /path/to/script contains connect user/pass@connect_identifier; and has permissions such that a normal user can't access it.

Upvotes: 2

Related Questions