wodby/php

Environment variables with equals signs are truncated in SSH sessions

Closed this issue · 0 comments

The awk script that produces /home/wodby/.ssh/environment breaks lines into parts by equals signs, but does not take third and subsequent parts when printing the output.

That results in all variable contents after first equals sign being lost in SSH sessions. In local shell sessions, the variables are left as defined in environment / env_file.

Environment

Ubuntu 22.04.4
Docker version 26.0.0, build 2ae903e
wodby/php:8.2-dev-4.48.0

Steps to reproduce

  1. Create minimal compose.yml:
services:
  sshd:
    image: wodby/php:8.2-dev-4.48.0
    environment:
      - "DATABASE_URL=postgresql://user:password@host:5432/mydb?serverVersion=16&charset=utf8"
    command: ["sudo", "/usr/sbin/sshd", "-De"]
    ports:
      - "2220:22"
    volumes:
      - ./authorized_keys:/home/wodby/.ssh/authorized_keys
  1. Copy contents of your id_rsa.pub to authorized_keys in same folder as compose.yml and set permissions to 600.
cp ~/.ssh/id_rsa.pub authorized_keys
chmod 600 authorized_keys
  1. Run the container and connect to sshd container via SSH and print the DATABASE_URL variable.
docker compose up -d
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2220 -i ~/.ssh/id_rsa wodby@127.0.0.1
echo $DATABASE_URL

Expected output

postgresql://user:password@host:5432/mydb?serverVersion=16&charset=utf8

Actual output

postgresql://user:password@host:5432/mydb?serverVersion

Notes

When executing Bash inside container, the variable is output as defined in compose.yml:

docker compose exec sshd /bin/bash
echo $DATABASE_URL
# postgresql://user:password@host:5432/mydb?serverVersion=16&charset=utf8

Also content of /home/wodby/.ssh/environment:

grep DATABASE_URL /home/wodby/.ssh/environment
# DATABASE_URL=postgresql://user:password@host:5432/mydb?serverVersion