Cannot connect to aws rds Postgresql using master password and username but pgAdmin works - sql

I Cannot connect to AWS rds Postgresql using master password and username but pgAdmin connection with the certificate works perfectly.
My website, when it tries to connect to the database, says:
net::ERR_CONNECTION_TIMED_OUT
I ssh into my ec2 instance of the Elastic Beanstalk and it gives me the following error when I am trying to connect to the rds:
psql: error: FATAL: PAM authentication failed for user "user"
FATAL: pg_hba.conf rejects connection for host "111.11.1.11", user "user", database "database", SSL off
The command I use to connect is this:
psql --host=rds_endpoint --port=5432 --username=user --password --dbname=database
I changed the master password and still, it does not work.
Again, If I use pgAdming with ssl certificate and that token that it generates, the connection is successful and I have full access to the database.
Also, the command
nc -zv rds_endpoint 5432
gives the successfull result:
Ncat: Connected to 111.11.11.11:5432.
The master username is and password does not contain any special character.
Master username: user

I have had this issue when the password contained special characters. I need to escape them in the connection URL used in psql
Percent-encoding may be used to include symbols with special meaning in any of the URI parts, e.g., replace = with %3D.
https://www.postgresql.org/docs/11/libpq-connect.html#id-1.7.3.8.3.6

Related

how to login in to psql with your admin details

hi am following the following tutorial
https://www.youtube.com/watch?v=qw--VYLpxG4&t=2224s
and when i add psql into my path and then type it into the terminal it asks for my administrator datails of which i give then it shows this
psql: error: FATAL: password authentication failed for user "aarushsharma"
how do i find out the password for aarushsharma?
try to change METHOD in pg_hba.conf file from md5 to trust, restart postgresql server and change your user password
ALTER USER aarushsharma WITH PASSWORD 'your_password';
and set METHOD to md5 again

Trying to create new PostgreSQL user, but receiving the error: "psql: FATAL: password authentication failed for user"

I am trying to create another superuser for my Postgresql database. I have managed to successfully create a new role with all the permissions using default postgres superuser.
However, when I am trying to log into the database using my new user with the password I have created for it, I am getting this error message: psql: error: could not connect to server: FATAL: password authentication failed for user "newuser"
Here is how my pg_hba.conf file looks like:
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
If I set all the methods to trust, I will be able to log in as the newuser, but since the database I am trying to set up will be public, I do not want to leave superuser without any passwords.
Also, the default postgres user also already has the password set up for it, but I can log into it with no issues.

beeline LDAP authentication with encrypted password file

I am using Beeline CLI to connect HiveServer2. I am using following command to connect:
beeline -u jdbc:hive2://myhost.abc.com:10000/default -n myuser -w pass_sa -e "show tables;"
Connection is successful and I am able to access the Hive database but here my password is not encrypted here I am trying to use encrypted password using password file.
I am going through with several link but having confusion with LDAP authentication and Encrypted password authentication and looking for help on this.
Since you have mentioned LDAP, I assume that you are using Kerberos and "myuser" is Active Directory or Kerberos realm account. You have to authenticate your user with "kinit" and then run beeline without user and password. Beeline should not ask for credentials.
Try to run those steps:
su - myuser
kinit (and type the "myuser" password)
beeline -u "jdbc:hive2://myhost.abc.com:10000/default" -e "show tables;"

Connecting to my server through SSH using Terminal - permission denied

I am trying to get access to my server via SSH using Terminal.
I have created a key in cPanel which required me to set a password. I'm trying to connect in Terminal using this password but it says Permission Denied.
I am trying connect by doing:
ssh mysite.co.uk
Am I doing something wrong?
Server wasn't SSH enabled properly. Switched servers to another provider and did:
ssh your_remote_username#mysite.co.uk
works fine.
You can try using following format:
ssh <Your user>#mysite.co.uk
Make sure that your user has correct right to connect via SSH.

PostgreSQL: Why can I connect to a user with a set password without having to give the password?

After creating a new user john with: CREATE USER john PASSWORD 'test';
CREATE DATABASE johndb OWNER john; I can connect to the PostgreSQL server with: psql -U john johndb The problem is that psql never asks me for the password. I realy need to know what's wrong, because of obvious reasons.
Your pg_hba.conf file probably has local connections set to "trust". The default contains a section like this:
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
This means that for all connections from the local machine, trust whatever the client says. If the client says "I am user john", then the server will permit that.
The PostgreSQL documentation has a whole section on the pg_hba.conf file.