Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication Error #2

Open
MagneticsRF opened this issue Jan 31, 2019 · 4 comments
Open

Authentication Error #2

MagneticsRF opened this issue Jan 31, 2019 · 4 comments

Comments

@MagneticsRF
Copy link

MagneticsRF commented Jan 31, 2019

etil@ETIL-RADIO:~/Desktop/mqtt-pwn$ python3 run.py
Traceback (most recent call last):
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2514, in connect
    self._state.set_connection(self._connect())
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 3068, in _connect
    conn = psycopg2.connect(database=self.database, **self.connect_params)
  File "/home/etil/.local/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL:  Peer authentication failed for user "postgres"


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2565, in execute_sql
    cursor = self.cursor(commit)
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2551, in cursor
    self.connect()
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2515, in connect
    self._initialize_connection(self._state.conn)
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2367, in __exit__
    reraise(new_type, new_type(*exc_args), traceback)
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 175, in reraise
    raise value.with_traceback(tb)
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2514, in connect
    self._state.set_connection(self._connect())
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 3068, in _connect
    conn = psycopg2.connect(database=self.database, **self.connect_params)
  File "/home/etil/.local/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
peewee.OperationalError: FATAL:  Peer authentication failed for user "postgres"


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run.py", line 9, in <module>
    create_all_tables(db)
  File "/home/etil/Desktop/mqtt-pwn/mqtt_pwn/database.py", line 49, in create_all_tables
    create_tables(db, _all_tables)
  File "/home/etil/Desktop/mqtt-pwn/mqtt_pwn/database.py", line 41, in create_tables
    db.create_tables(tables)
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2715, in create_tables
    model.create_table(**options)
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 5445, in create_table
    and cls.table_exists():
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 5435, in table_exists
    return meta.database.table_exists(meta.table, meta.schema)
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2693, in table_exists
    return table.__name__ in self.get_tables(schema=schema)
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 3092, in get_tables
    cursor = self.execute_sql(query, (schema or 'public',))
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2574, in execute_sql
    self.commit()
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2367, in __exit__
    reraise(new_type, new_type(*exc_args), traceback)
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 175, in reraise
    raise value.with_traceback(tb)
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2565, in execute_sql
    cursor = self.cursor(commit)
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2551, in cursor
    self.connect()
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2515, in connect
    self._initialize_connection(self._state.conn)
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2367, in __exit__
    reraise(new_type, new_type(*exc_args), traceback)
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 175, in reraise
    raise value.with_traceback(tb)
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 2514, in connect
    self._state.set_connection(self._connect())
  File "/home/etil/.local/lib/python3.6/site-packages/peewee.py", line 3068, in _connect
    conn = psycopg2.connect(database=self.database, **self.connect_params)
  File "/home/etil/.local/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
peewee.OperationalError: FATAL:  Peer authentication failed for user "postgres"
`
```



```

`# DB Related
DB_NAME = 'mqttpwn'
DB_USER = 'postgres'
DB_PASSWORD = '7BYGQMWvzwBDCpJebPAbBkbQaaxXZKVHm7jc7rWFEaHtCPU4KEXmytiFBjK3f6oP'
DB_HOST = os.getenv('MQTTPWN_DB_HOST', '/var/run/postgresql')
DB_PORT = os.getenv('MQTTPWN_DB_PORT', 5432)

BASE_PATH = os.getenv('MQTTPWN_BASE_PATH', '/Users/dabeles/Documents/Code/Python/mqtt-pwn/')`
```




Having issues connecting to the server, in the documentation it only says:
"In order for the application to work properly, a PostgreSQL database is required. After configuring it correctly, follow the next section to install the virtual environment, on the first run of the application, it will create automatically all required tables."

with no instructions to configure the server, 


I have set up a psql server named mqttpwn owned by the user postgres. I have tried to set the password, and remove the password a milllion different ways and I get the same Authentication error. 

Any help would be appreciated. Thanks
@Den1al
Copy link
Contributor

Den1al commented Jan 31, 2019

Did you set the corresponding host, port and password?

@MagneticsRF
Copy link
Author

Yes, I believe so. I Have tried setting custom password and port, as for host, IM unsure, i am trying to set it up locally

@Den1al
Copy link
Contributor

Den1al commented May 8, 2019

Did you manage to authenticate successfully?

@jmessiasalves
Copy link

jmessiasalves commented Jun 2, 2020

I recommend creating a user on PostgreSQL, setting the user's permissions for the created mqttpwn database, and adding connection permissions in the pg_hba.conf file.

#su - postgres
$ pqsql

postgres = # CREATE DATABASE mqttpwn;

postgres = # CREATE USER mqttpwn_user INHERIT CREATEDB CREATEROLE;

postgres = # ALTER USER mqttpwn_user PASSWORD 'your_password';

Add the following line to the pg_hba.conf file:

host all mqttpwn_user 127.0.0.1/32 password

The lines in the config.py file will look like:

DB_NAME = 'mqttpwn'
DB_USER = 'mqttpwn_user'
DB_PASSWORD = 'your_password'
DB_HOST = os.getenv ('MQTTPWN_DB_HOST', 'localhost')
DB_PORT = os.getenv ('MQTTPWN_DB_PORT', 5432)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants