Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

1.9 KB
Raw Blame

SSH bastion test fixture

Throwaway credentials for the SSH tunnel tests. None of this material is secret, and none of it grants access to anything - the keys are generated for this directory, live only inside a container built at test time, and are regenerated by anyone who wants to.

A secret scanner will flag test_key and test_key_passphrase as private keys. That is expected, and matches the already-committed PEM material under internal/features/tests/logical/postgresql/testdata/.

Files

File What it is
Dockerfile Alpine + OpenSSH bastion. Creates the testuser account and sets its password.
sshd_config Permits TCP forwarding and adds a second listener on 2222.
authorized_keys Public halves of both keys below.
test_key Passphrase-less ed25519 private key, for the public-key auth test.
test_key_passphrase ed25519 private key protected with the passphrase testpassphrase.

Account baked into the image: testuser / testpassword.

Why sshd listens on 2222

The tunnel tests forward to port 2222 rather than 22. Port 2222 is never published to the host, so a forwarder that stopped tunnelling and dialled the host loopback instead cannot accidentally reach a developer's or CI runner's own sshd and pass. Test_TargetPort_WithoutTheTunnel_IsUnreachableFromTheHost pins that property.

Regenerating

cd backend/internal/util/testing/containers/testdata/ssh_bastion
rm -f test_key test_key_passphrase authorized_keys

ssh-keygen -t ed25519 -N "" -C "databasus-sshtunnel-test" -f test_key
mv test_key.pub authorized_keys

ssh-keygen -t ed25519 -N "testpassphrase" -C "databasus-sshtunnel-test-passphrase" -f test_key_passphrase
cat test_key_passphrase.pub >> authorized_keys
rm test_key_passphrase.pub

The passphrase is asserted verbatim in forwarder_test.go; changing it means changing the test.