0

I set up a postgres DB on my server, logged in with postgres (PEER Method), created another user and than want to set an encrypted password for the new user.

The most tutorials I find say, that you can change the password by:

ALTER USER other_user WITH ENCRYPTED PASSWORD 'passwd';

But it does not really feel good to enter the password clear into the sql console. It is saved in the history, and everybody can see it.

Is this really the right way to set a password in postgres?

2
  • Not everyone, only people you are willing to allow super user access. If you have a bunch of people logging in with super user access, then you have much bigger problems that this one. Commented Jun 14, 2015 at 18:41
  • Hehe, yes, you are right, nobody has access to it. It just does not feel right to save it in plain text in a history. Commented Jun 15, 2015 at 5:51

1 Answer 1

1

I have a ~/.pgpass in my home :

localhost:5432:*:postgres:123456

and the query file password.txt :

ALTER USER other_user WITH ENCRYPTED PASSWORD 'passwd';

and run this command:

psql -U useradmin -h localhost -w -a -E -f password.txt 

Remember:

rm .psql_history
Sign up to request clarification or add additional context in comments.

2 Comments

Ok, good idea, this works, but it is really impractical
If you are the admin?. You can set the password, as admin. Nobody can see your history.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.