Skip to content
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

Environment variables with equals signs are truncated in SSH sessions #190

Closed
andrew-drupal opened this issue Mar 27, 2024 · 0 comments · Fixed by #191
Closed

Environment variables with equals signs are truncated in SSH sessions #190

andrew-drupal opened this issue Mar 27, 2024 · 0 comments · Fixed by #191

Comments

@andrew-drupal
Copy link

andrew-drupal commented Mar 27, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant