sysPass icon indicating copy to clipboard operation
sysPass copied to clipboard

Access Denied to DB

Open knightowl1000 opened this issue 7 years ago • 16 comments

sysPass Version Syspass V2

Describe the question After server power off, the docker containers change IPs for syspass-app and syspass-db. I was getting this error message: 2019-01-03 11:31:39 - Unable to connect to the DB 2019-01-03 11:31:39 - Error 2002: SQLSTATE[HY000] [2002] Connection refused

I went into the config.xml file and I changed the IP of the db to the new one. I then logged into the mysql db and updated the IP for the syspass-app and now i'm getting this:

2019-01-03 11:50:26 - Unable to connect to the DB 2019-01-03 11:50:26 - Error 1045: SQLSTATE[HY000] [1045] Access denied for user 'sp_admin'@'syspass-app.docker_default' (using password: YES)

I'm unsure why i'm getting this error.

+------------------+----------------------------+ | user | host | +------------------+----------------------------+ | root | 127.0.0.1 | | sp_admin | 172.18.0.4 | | sp_admin | 30da97fd035c | | root | ::1 | | root | a861c98d2687 | | debian-sys-maint | localhost | | root | localhost | | root | syspass-app.docker_default | +------------------+----------------------------+

I tried following the following instructions: https://github.com/nuxsmin/docker-syspass/issues/13 but it doesn't like the password. It wants a 41 hex password.

Platform (please complete the following information):

  • OS: Linux
  • OS Version: CentOS 7

knightowl1000 avatar Jan 03 '19 18:01 knightowl1000

Hello, it seems that sysPass docker's network is not syspass-app.syspass_default. Please set either the correct DNS name or an IP address.

Regards

nuxsmin avatar Jan 03 '19 19:01 nuxsmin

Hi @nuxsmin - Do I just do that on the host? Also, it seems you've removed syspassv2 from hub.docker.com

knightowl1000 avatar Jan 03 '19 19:01 knightowl1000

Updated my hosts file to have: 172.18.0.4 syspass-app.syspass_default Restarted the container, and it still is not able to connect

knightowl1000 avatar Jan 03 '19 19:01 knightowl1000

it seems you've removed syspassv2 from hub.docker.com

They are pointing to v3 instead, anyway I've just tagged latest images for 2.1

Updated my hosts file to have: 172.18.0.4 syspass-app.syspass_default

This wouldn't work, since host resolution is being done inside the containers. You can update the database user's host field to point to the sysPass container's IP address.

nuxsmin avatar Jan 03 '19 21:01 nuxsmin

I have tried that. The IP of 172.18.0.4 is the new IP of the syspass container. I took a SQL dump from mysql and i'm trying to import it into a v3 version. Is there a way to do that successfully? When I imported the db into the new Msql, the application states that it has an error checking the db.

knightowl1000 avatar Jan 03 '19 21:01 knightowl1000

I took a SQL dump from mysql and i'm trying to import it into a v3 version

That is not the right way. Please follow the steps on https://doc.syspass.org/updating/v3.html

sysPass will migrate v2 database to v3, do not try to place v2 data structure into the v3 one.

nuxsmin avatar Jan 03 '19 22:01 nuxsmin

Please let me know if these steps worked.

nuxsmin avatar Jan 03 '19 22:01 nuxsmin

Hi @nuxsmin - The documentation doesn't include how to restore the database to a brand new mysql server. Like, how to import it, how to change the connection user/pass to make sure it aligns. If I'm missing something, please do let me know!

knightowl1000 avatar Jan 04 '19 08:01 knightowl1000

Hey @nuxsmin - Any ideas? If we're not able to do that kind of recovery...is there a way to decrypt the passwords outside of syspass? I still have the master password saved somewhere.

knightowl1000 avatar Jan 07 '19 15:01 knightowl1000

Hey, currently there's only a tool for decrypting an exported XML file, but not to decrypt the database data. sysPass relies on OpenSSL tools and AES-256 algorithm through php-encryption library, so data could be decrypted by using the library API.

Regards

nuxsmin avatar Jan 07 '19 15:01 nuxsmin

Hi @nuxsmin - Finally restored syspass, I am able to login with my LDAP account but I am unable to see any accounts. I checked the DB, and I see the accounts in the accounts table. What do you recommend one do?

knightowl1000 avatar Jan 07 '19 20:01 knightowl1000

@knightowl1000 it might by a database views permission issue, since account_search_v and account_data_v would have been created using the root account. You would need to remove the lines /*!50013 SQL SECURITY DEFINER */ within dump file

nuxsmin avatar Jan 07 '19 21:01 nuxsmin

The SQL dump file? I don't see that line.

When I looked at the logs, I see the following: 2019-01-07 21:58:38 - Error while querying SQLSTATE[28000]: Invalid authorization specification: 1045 Access denied for user 'sp_admin'@'127.0.0.1' (using password: YES) (0)

knightowl1000 avatar Jan 07 '19 21:01 knightowl1000

Yes, did you export the old database data?

nuxsmin avatar Jan 07 '19 21:01 nuxsmin

Yes. After your comment and looking into permissions, I forgot to do a FLUSH PRIVILEGES. After that, I can see everything!!!

Thank you soo much for your support @nuxsmin - We were about to start rebuilding all of our servers. This time, I'm going to architect this better.

knightowl1000 avatar Jan 07 '19 21:01 knightowl1000

Sure, glad to hear it worked fine!

nuxsmin avatar Jan 07 '19 21:01 nuxsmin