psql: FATAL: password authentication failed for user windows 8 - windows

I installed postgresql on windows and while the installation it asks to make a user for the account.This made a new windows user in my computer called postgres, I have created a password for it as well.
Now I want to run psql on windows command line, it asks for a password (without mentioning the user) and always gives me back the error: psql: FATAL: password authentication failed for user "Ash". Even though I have put my accounts password many times.
using pgadmin I changed the user "postgres" to "Ash" but I have yet to remake the password. I followed the steps here: I forgot the password I entered during postgres installation (I rather types host all 127.0.0.1/32 trust because I am on windows), but when running psql again so that I can change the password I get the error: psql FATAL:could not load pg_hba.conf. All together.
Why can it not load? All I did was add an extra authentication option.
Also, is the windows user separated from a postresql user or are they the same(depend on each other)?
Edit:
As you can see, it did not give me the option to choose if Aisha should be a superuser or not. or the other options for that matter.
I also used pgadmin||| to create a new user but the same error pops up:
The user does not exist so why does it do this?

The user on your machine has nothing to do with the user on PostgreSQL. The installer just creates an account and a PostgreSQL role with the same name and password (which in my mind is a bad idea), but they're not related in any way. The Windows user is used to run the server, the PostgreSQL role is used inside the database.
So you should first access the server with the user postgres and then create a user for yourself. Don't change the username inside the server, or the server's running user! Just create a new username and grant it the permissions you need.
You can use psql -U postgres to connect to the server and it'll ask for the password.
Check the permissions for pg_hba.conf, the postgres user must have permissions for it. If you only edited it as an admin, it should be ok, but if you took permissions or anything else, it may mess it up.

createuser is a command-line utility. Use CREATE USER username WITH PASSWORD 'fred'; or similar at the SQL level in psql. Note the semicolon.
What you're doing in your screenshot is starting to write an SQL command beginning with createuser, but never sending it to the server to run because there's no semicolon terminator. So you never get the error that would tell you it doesn't make sense to do that.

I had exactly the same problem and this line solved it;
createuser --createdb -U postgres --login -P 'your_new_user'
#sami-kuhmonen was right, but his approach of solving the problem did not work for me.

This can also happen if the encryption for stored passwords does not match the encryption for connections as defined in postgresql.conf ang pg_hba.conf
For example, if postgresql.conf has:
password_encryption = md5
but pg_hba.conf has:
host all all 10.0.0.110/24 scram-sha-256
Then all connections on the 10.0.0.110 interface will have the 'FATAL: password authentication failed error'.
Remember that if you change either of these files you will need to restart postgresql and if you change the password encryption in postgresql.conf you will need to change the passwords for all of the users.
Hope this helps some others with this problems.

I was having the same error. I get to solve it by locating the "pg_hba.conf" file. You can use this navigation:
C:\Program Files\PostgreSQL\14\data\pg_hba.conf
Then inside the file, changed all the methods "scram-sha-256" to trust and problem was solved.

Related

passing username/password to openVPN CLI directly

I want to make a script that asks the user for username and password and uses these for a few things at once, including connecting to OpenVPN without needing to either
store the password on the disk
ask the user for the data many times over
for example you can run net use with user and password to mount shares, however openVPN seemingly only has an option to pass a file with username and password.
On Linux there seemingly are solutions like this, however I don't seem to find anything similar for windows yet.
Is there a solution?

How to reset password for Shield in Elasticsearch

Context: Setting up Shield on my local machine for a 1 node Elasticsearch
Machine: Mac OSX 10.9.5
After installing Shield, I tried adding admin users but failed to do so because initially I did not restart my ES. During this attempt, I tried a bunch of username and password combinations(My bad here).
After I was pointed out that I had to restart ES before creating any users, I did so. Now, everytime I open localhost:9200 on my browser, I am required to provide a username and password.
I have tried most of the combinations that I 'attempted' to create earlier, but non seems to be the right one.
Upon running the bin/shield/users, it shows that I have one user which is my machine name. Tried again a bunch of possible passwords that I could think of, but nothing seems to be the right one. Below is the error I'm getting
{"error":"AuthenticationException[unable to authenticate user [username]
for REST request [/_shield]]","status":401}
So, any idea on how I could reset the password or the delete the user entirely ??
Use the esusers userdel username command to delete that username and add another one of your choice.

How to check if a svn command needs authentication

Is there any possible way to check if a SVN update needs authentication or not?
Scenario : I have written a ruby GUI app which updates SVN repositories (from a static path) in a scheduled manner. This executes as a windows service. Also have tortoisesvn installed.
In ruby when I execute
svn update local_path_to_repository --username user --password password in my script then it works fine as I am passing the username & password with the update command.
But, tortoisesvn saves the password (by caching password, using standard Windows cryptography services to encrypt the password on disk) when I checkout the repository for the first time so I don't necessarily need to pass the username and password every time. Thus I just have svn update local_path_to_repository in my script.
Issue: This works fine until I change my LDAP password. Once my LDAP password is changed all the repository fails to get updated as it is requesting for the new password but there is no user interface for passing the new password.
I need to build the username and password UI only when svn updates needs those credentials but not always. How do I achieve this?
Update : Reading from the SVN book. I Understood that:
The client checks whether the user specified any credentials as command-line options (--username and/or --password). If not, or if these options fail to authenticate successfully, then
The client looks up the server's hostname, port, and realm in the runtime auth/ area, to see if the user already has the appropriate credentials cached. If not, or if the cached credentials fail to authenticate, then
Finally, the client resorts to prompting the user (unless instructed not to do so via the --non-interactive option or its client-specific equivalents).
But I did not find a way to check if authentication is required.
Can anyone please help me!
So I finally found a work around by doing:
output = `svn update "#{repo_path}" --non-interactive 2>&1`
check_authentication = output.include?("Authentication failed")
if check_authentication returns true meaning authentication has failed then I build the GUI for entering the new password and send it to the user.

Ruby -> PostgreSQL connection with pg_hba.conf set to "ident sameuser" instead of "trust"

I've tried every Google search term I can think of but everything I dig up keeps saying to set local connections to trust in pg_hba.conf (seems like a security hole if anyone locally can log in and access the DB as anyone they say they are).
In pg_hba.conf local connections are set to ident sameuser. The script should be running as that user, but I get this error:
A database error occurred:
fe_sendauth: no password supplied
The Ruby code is pretty generic:
conn_str = "DBI:pg:dbname=mydb;host=" + localhost
#connection = DBI.connect(conn_str, "myuser", '')
I can work around this by creating a ~/.pgpass file as described here,
but I'd prefer being able to let users log in and just access the DB server.
Anyone ever been able to get PostgreSQL's ident sameuser to work properly for local scripts?
I suspect this:
In pg_hba.conf local connections are set to ident sameuser. The script should be running as that user, but I get this error [...]
conn_str = "DBI:pg:dbname=mydb;host=" + localhost
#connection = DBI.connect(conn_str, "myuser", '')
Please note that a "local" connection is not the same as a connection to "localhost". As soon as you mention "localhost" in the connection URL a TCP/IP socket is created. These are managed by the host rules in `pg_hba.conf.
To use a real "local" connection Unix Domain Sockets must be used. But I don't know whether or not the Ruby DBI connector supports them.
The ident setting works for me for local system users and PostgreSQL 8.4. You may have to adjust your pg_hba.conf settings.
Check your database log files to see where the connections come from exactly and whether the system user name matches the database role name. You may have to activate log_connections in your postgresql.conf for that.
The manual really does a nice job explaining authentication methods.
If system user name and database role name don't match, you'll have to use a .pgpass file. But your passwords should still be safe. Only the system user postgres gets to read it. I quote the manual:
On Unix systems, the permissions on .pgpass must disallow any access
to world or group; achieve this by the command chmod 0600 ~/.pgpass.

Oracle database created but invalid username/password

I'm using Windows 7 64-bit os with oracle 11g. I created a database succesfully. i'm loging in using sqlplus with correct username/password, but it giving the invalid username/password. Logon denied. We are more than 10 people using the same kind of machine and softwares and everyone following the same documentation for installation. Except me every one can able to login properly. What's the problem ? I'm not changed any username and password. Is system side issue or installation problem or database setup problem?
Unlikely to be database or installation related. Pre 11g, with case-insensitve passwords, very
exotic passwords could give trouble if the uppercase value of the password was different depending on NLS settings.
Could be a 'sticky key' when you entered the password during installation. Or, if you touch type, you might have been offset by a key.
try a "sqlplus / as sysdba"
If that works, reset the password with ALTER USER username IDENTIFIED BY password
If you can't get in as sysdba you should try using a Windows admin account.
In 11G passwords are case sensitive. So make sure you type in your password correctly.
What was the password you used when creating the new user ?
Oracle 11 G and 12 C versions suggest to use more complex passwords, Although there is no issues during the user creation. The password must be alphanumeric and with special character.
Verify the password version and status of the user:
select * from dba_users where username = <user_name>;
Amend it to be like below in case of 11G 12C:
alter user <user_name> identified by Pass2019$;
Now test connection!

Resources