-
Notifications
You must be signed in to change notification settings - Fork 0
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
Open postgres to listen on the network and enforce protection with a random password #15
Changes from 9 commits
3d03c0f
0c7d21e
e4fdb8a
c948351
8be16b2
d04f677
19e551b
6b976a7
03630d2
d431af8
8005d05
7b6cf6f
7c067fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Copyright (C) 2024 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
../bin/create-secrets |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,22 @@ | ||||||
#!/bin/bash | ||||||
|
||||||
# | ||||||
# Copyright (C) 2024 Nethesis S.r.l. | ||||||
# SPDX-License-Identifier: GPL-3.0-or-later | ||||||
# | ||||||
|
||||||
set -e | ||||||
|
||||||
|
||||||
|
||||||
if [[ ! -d ~/.config/state/secrets ]]; then | ||||||
/usr/bin/mkdir -p ~/.config/state/secrets | ||||||
fi | ||||||
|
||||||
# restict to 400 | ||||||
umask 266 | ||||||
|
||||||
if [[ ! -f ~/.config/state/secrets/passwords.secret ]]; then | ||||||
password_postgres=$(/usr/bin/openssl rand -hex 20) | ||||||
/usr/bin/echo "POSTGRES_PASSWORD=$password_postgres" > ~/.config/state/secrets/passwords.secret | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's an environment file syntax
Suggested change
|
||||||
fi |
This file was deleted.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is upgrade necessary? Shouldn't existing installations be already hardened? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Upgrade is necessary to change the postgres password from Nethesis,1234 to a random one Else you could connect easily you know it |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Copyright (C) 2024 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
# If the control reaches this step, the service can be enabled and started | ||
|
||
set -e | ||
|
||
# Redirect any output to the journal (stderr) | ||
exec 1>&2 | ||
|
||
# we want to migrate from 1.0.5 when the postgres password was default and no secrets were created | ||
|
||
if [[ ! -f ~/.config/state/secrets/passwords.secret ]]; then | ||
../bin/create-secrets | ||
source ~/.config/state/secrets/passwords.secret | ||
# change the password of the postgres user | ||
podman exec -ti postgresql-app sh -c "PGPASSWORD=${POSTGRES_PASSWORD} psql -U postgres -d postgres -c \"ALTER USER postgres WITH PASSWORD '${POSTGRES_PASSWORD}';\"" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the firewall command required to open that port? Please, make an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without tls encryption I am not sure to open a tcp port is smart. I can be wrong