lesspass / lesspass

:key: stateless open source password manager
https://www.lesspass.com
GNU General Public License v3.0
5.72k stars 325 forks source link

Self-Hosted Install Failure #74

Closed philip-ulrich closed 7 years ago

philip-ulrich commented 7 years ago

Hey Guys!

Not sure what's going on with the self install, but I can't get it to work. The website loads, but it does not connect to the database for the only reason I want to self host... connected version.

Relevant logs:

[root@pass LessPass]# docker logs lesspass_backend_1 
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 199, in ensure_connection
    self.connect()
  File "/usr/local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 171, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/usr/local/lib/python3.5/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/usr/local/lib/python3.5/site-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
psycopg2.OperationalError: FATAL:  password authentication failed for user "postgres"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 83, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/usr/local/lib/python3.5/site-packages/django/db/migrations/executor.py", line 20, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/usr/local/lib/python3.5/site-packages/django/db/migrations/loader.py", line 52, in __init__
    self.build_graph()
  File "/usr/local/lib/python3.5/site-packages/django/db/migrations/loader.py", line 203, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/usr/local/lib/python3.5/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
    self.ensure_schema()
  File "/usr/local/lib/python3.5/site-packages/django/db/migrations/recorder.py", line 52, in ensure_schema
    if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
  File "/usr/local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 233, in cursor
    cursor = self.make_cursor(self._cursor())
  File "/usr/local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 204, in _cursor
    self.ensure_connection()
  File "/usr/local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 199, in ensure_connection
    self.connect()
  File "/usr/local/lib/python3.5/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 199, in ensure_connection
    self.connect()
  File "/usr/local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 171, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/usr/local/lib/python3.5/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/usr/local/lib/python3.5/site-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
django.db.utils.OperationalError: FATAL:  password authentication failed for user "postgres"
[root@pass LessPass]# docker logs lesspass_db_1 
LOG:  database system was shut down at 2016-11-12 22:16:55 UTC
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started
LOG:  incomplete startup packet
FATAL:  password authentication failed for user "postgres"
DETAIL:  Connection matched pg_hba.conf line 95: "host all all 0.0.0.0/0 md5"

For what it's worth I've scrubbed my environment twice trying to get it to work to no avail:

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)

On a side note, you should really integrate letsencrypt with your 1-liner package or at least make it an option. Unless you want to just put a guide together for the self hosted version. Then you could just tell them to get a cert initially and then use a script like this to renew it:

#!/bin/bash

cd /opt/LessPass; docker-compose pull 

certbot renew 
cp /etc/letsencrypt/live/pass.l33t.tech/fullchain.pem /opt/LessPass/ssl/pass.l33t.tech.crt 
cp /etc/letsencrypt/live/pass.l33t.tech/privkey.pem /opt/LessPass/ssl/pass.l33t.tech.key

docker-compose down
docker-compose up -d
guillaumevincent commented 7 years ago

Hi, you can check:


services:
  db:
   ...
    environment:
      POSTGRES_DB: 'postgres'
      POSTGRES_USER: 'postgres'
      POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
  backend:
    ...
    env_file:
      - .env
    ...

For the letsencrypt you are right, we need to work on it

philip-ulrich commented 7 years ago

Hey,

Thanks for the reply. I have checked that and I do have both. I've even tried putting the password directly into the docker-compose.yml instead of the pulling it from the .env. No luck.

Jestre commented 7 years ago

I am seeing the same error. I found out about the project today, installed the docker components, but when I try to register the spinner does its thing, then returns with no other message. Trying to sign in fails.

Checking the docker logs, I see the above error re: postgres bad password. My .env file was created, and does have a password.

philip-ulrich commented 7 years ago

I was able to fix this.

@Jestre Try this: Stop docker containers:

> docker stop $(docker ps -a -q)
6312e1430a5b
27c9924918a7
e51044141a60
63fe057464f7

Remove docker containers:

> docker rm $(docker ps -a -q)
6312e1430a5b
27c9924918a7
e51044141a60
63fe057464f7

Remove docker images:

> docker rmi $(docker images -q)
Untagged: docker.io/lesspass/frontend:latest
...
Untagged: docker.io/postgres:9.5
...
Untagged: docker.io/lesspass/nginx:latest
...
Untagged: docker.io/lesspass/backend:latest
...

Find existing volumes:

> docker volume ls
DRIVER              VOLUME NAME
local               lesspass_www
local               lesspass_postgresql

Remove volumes:

> docker volume rm lesspass_postgresql
> docker volume rm lesspass_www

Make sure volumes are gone:

> docker volume ls
DRIVER              VOLUME NAME

Pull the images down again:

> docker-compose pull
Pulling frontend (lesspass/frontend:latest)...
Trying to pull repository docker.io/lesspass/frontend ... 
latest: Pulling from docker.io/lesspass/frontend
...
Digest: sha256:00696ee643e10464fd4a2cf4380d0996860391c3a0d67e2626fd7595d25d145d
Status: Downloaded newer image for docker.io/lesspass/frontend:latest
Pulling db (postgres:9.5)...
Trying to pull repository docker.io/library/postgres ... 
9.5: Pulling from docker.io/library/postgres
...
Digest: sha256:c799bacde4426c0e57aaba7b2b90bd1d6ae61e5a7edbd6f36586ad2efea4444b
Status: Downloaded newer image for docker.io/postgres:9.5
Pulling backend (lesspass/backend:latest)...
Trying to pull repository docker.io/lesspass/backend ... 
latest: Pulling from docker.io/lesspass/backend
...
Digest: sha256:75fbf17c4bd059d5270f2606b5486fb18456b870a3bd9478841e60124baeec69
Status: Downloaded newer image for docker.io/lesspass/backend:latest
Pulling nginx (lesspass/nginx:latest)...
Trying to pull repository docker.io/lesspass/nginx ... 
latest: Pulling from docker.io/lesspass/nginx
...
Digest: sha256:672c2982b772791ee3ab453703ba7c790fa06221cbb4cbfba91421f8c932fae7
Status: Downloaded newer image for docker.io/lesspass/nginx:latest

Start it back up:

> docker-compose up -d
Removing network lesspass_default
Creating network "lesspass_default" with the default driver
Creating volume "lesspass_www" with default driver
Creating volume "lesspass_postgresql" with default driver
Creating lesspass_frontend_1
Creating lesspass_db_1
Creating lesspass_backend_1
Creating lesspass_nginx_1

Check for errors again. Hopefully there are none.. This fixed it for me!

Jestre commented 7 years ago

@philip-ulrich Looks like that did it! Not sure what or how, but all seems to be working.

Also, the warning I was getting about an unsafe script is now gone also, so the Let's Encrypt certs are working too.

Thank you very much.

philip-ulrich commented 7 years ago

👍 I'll go ahead and close this out.