3

I have sshd set up in a remote host with bunch of environment variables set. Then I ssh'd into it and get the following with: ps

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0 112868  4208 ?        Ss   19:27   0:00 /usr/sbin/sshd -D -e
root       127  0.0  0.0 148480  5372 ?        Ss   19:34   0:00 sshd: root@pts/0
root       129  0.0  0.0  13392  1892 pts/0    Ss   19:34   0:00 -bash

Current pid is 129. Its parent is 127, whose parent is 1.

How do I get my current ssh session to have all environment variables from the initial sshd process? Both the current process and its parent don't have environment variables that are set in sshd.

1
  • 1
    Environment of sshd has nothing to do with environment of your ssh sessions. Look at the answers there May 27, 2019 at 18:10

1 Answer 1

-2

Actually SSH should have the default system environment variables.
This means that its variables should be from the following files: /etc/environment, /etc/profile, /etc/profile.d/, /etc/bash.bashrc. A lot of the variables are shell specific though;

Since you're using bash you'll automatically execute /etc/bash.bashrc and the user-specific login scripts upon shell creation.

To get the environment variables from those files, just execute them before running anything else.

Sources:
https://askubuntu.com/questions/26318/environment-variable-vs-shell-variable-whats-the-difference https://www.tecmint.com/set-unset-environment-variables-in-linux/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .