We have a user named billing_viewer for doing ad-hoc queries, but we'll need to set the password.

We'll need to logon to the instance to do this.

To log on to the instance, we need the username, the ssh key, and the hostname.

The username is ec2-user.

For this example we'll have $HOME/.ssh/key_name.pem be the SSH private key. And we'll have the hostname be PublicDNS. Be sure to replace these with the appropriate values when doing this yourself.

Console - user@localhost ~ $

1
ssh -i $HOME/.ssh/key_name.pem ec2-user@PublicDNS

One-liner

Once logged in, we'll run the following command, but replace billing_viewer_password with your desired password:

Console - user@PublicDNS ~ $

1
sudo -u postgres psql -c "ALTER USER billing_viewer WITH PASSWORD 'billing_viewer_password'"

No Echo

While not as convenient, we can change the password without it being seen as we type it.

We'll log in to postgresql as the postgres superuser.

Console - user@PublicDNS ~ $

1
sudo -u postgres psql

Then we'll do the \password command.

psql - postgres=#

1
\password billing_viewer

We'll then be prompted to Enter new password:. We'll put in our desired password, it won't be echoed back as we type, then press Enter. Then we'll be prompted Enter it again: to make sure we put it in correctly.

Finally we'll exit psql:

psql - postgres=#

1
\q