Skip to content

[Bug]: No run env vars in non-login SSH session #3343

@un-def

Description

@un-def

Steps to reproduce

Apply the configuration:

# dev-environment.dstack.yml
type: dev-environment
name: dev-environment
ide: vscode
env:
  - RUN_VAR=1
  1. Log in and run command:

    $ ssh dev-environment
    root@a6e6bda7be8e:/# printenv SHELL CUDA_VERSION DSTACK_RUN_NAME RUN_VAR
    
  2. Run the same command via ssh:

    $ ssh dev-environment printenv SHELL CUDA_VERSION DSTACK_RUN_NAME RUN_VAR
    

Variable sources:

  • SHELL — set by sshd
  • CUDA_VERSION — from the image
  • DSTACK_RUN_NAME — injected by dstack
  • RUN_VAR — declared in the run configuration

Actual behaviour

  1. /bin/bash
    12.8.1
    dev-environment
    1
    
  2. /bin/bash
    

Expected behaviour

The output in the second case should be the same.

dstack version

a49d34c43913f0962ed8b5b7da6f28dea621186f

Server logs

Additional information

dstack exports vars in /dstack/profile, which is sourced in /etc/profile, which, in turn, only sourced by login shells, while ssh destination command [argument ...] executes command in a non-login shell.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions