HowTo: Create scram-sha-256 password hash for use with postgres
If you need to pre-generate a scram-sha256
password hash for use with postgres, e.g. for using it with config management like puppet, pre-generating the password hash can be done in a small oneliner on any machine that has postgres installed:
$ createuser -e dummy --pwprompt && dropuser dummy
Enter password for new role:
Enter it again:
SELECT pg_catalog.set_config('search_path', '', false);
CREATE ROLE dummyuser PASSWORD 'SCRAM-SHA-256$4096:QJQsradJegC1DjzhWFAUEw==$l60VVp5kOM1YzLBqv7mRxZ7A0J31dQgV69Ugzkj/Frc=:ZhqSB6yXeV+Cf+5Q32fylOoukYJrutprcDmzYwM3pTY=' NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;
and the salted password hash can be retrieved between the single quotes after PASSWORD
.
The -e
option means echo
.
Related cards:
Manually create Postgres password hash
For some reason you have to pass the password hash if you want to create a role in postgres. To calculate the hash use the following snippet:
echo -n "md5"; echo -n "${PG_PASSWORD}${PG_USERNAME}" | md5sum | awk '{print $1}'
HowTo Generate Nagios Config with puppet fast
Creating Nagios Config with puppet
Let's have a look at the classic way of managing Nagios configuration with exported Puppet resources.
Here is [a good article about the topic](https://www.ericholzbach.net/blog/automating-nagios-with-puppet-a...
Restoring old Postgres dumps with pg_restore v11 and higher
There is an issue with when restoring a PostgreSQL dump created with pg_dump
< v11 with pg_restore
> v10:
pg_restore: [archiver (db)] could not execute query: ERROR: schema "public"
already exists
Command was: CREATE SCHEMA public;
`...
HowTo: Get postgres shell in kubernetes
If your postgres database is only accessible from inside a kubernetes cluster, e.g. if it's configured in AWS RDS and not available to the public (as it should be!), here's how to open a psql
shell inside Kubernetes and connect to the database. ...
HowTo: Fix nginx not reloading with long gzip_types lines
When using many or very long entries of MIME-types that shoudl be gziped in gzip_types
directives in nginx
you might not be able to successfully reload the service and get this error message instead:
nginx: [emerg] could not build the tes...
create htpasswd entry and print to stdout
Create htpasswd entry and print to stdout:
$ sudo apt install apache2-utils # Optional
$ htpasswd -n $USERNAME
New password:
Re-type new password:
$USERNAME:<Password Hash>
HowTo: Clone a MariaDB database with mariabackup, mbstream and netcat
If you have a very large datadir in MariaDB and you want to transfer the data to another host (e.g. for replication) you may want to avoid storing it locally and copying it between the hosts.
You can stream the backup directly via netcat
.
##...
Use systemd-run as an alternative for screen
You might use screen
or tmux
to run a temporary command on a server which continues to run after the SSH session is closed.
Consider systemd-run
as alternative. It will turn every command in a systemd ser...
Use Ubuntu 24.04 (Noble Numbat) with Vagrant
Canonical does not ship Ubuntu 24.04+ Vagrant images due to HashiCorps switch to the [Business Source License (BSL)](https://www.hashicorp.com/...
HowTo: Curl applications that are usually behind reverse proxies with TLS termination without the application redirecting to https schema
A lot of web applications require being called over https
, which is a good thing. It's possible to configure this requirement at the web- or proxy server level, where nginx
or apache
will just redirect every request on http
to https
. Som...