비 대화식 SSH에 대한 환경 변수 설정 대해 환경 변수를 설정하기에 가장 적합한 장소는

모든 (대화식이 아닌) ssh 세션 및 모든 사용자 (루트 포함)에 대해 환경 변수를 설정하기에 가장 적합한 장소는 어디입니까?

나는 아래의 스크립트에있을 수 있다고 생각 /etc/profile.d/하지만 변경 사항이 구성의 다른 영향을 미치지 않을 것이라고 확신하지 않습니다.



답변

로부터 sshd(8)man 페이지, 파일 섹션 :

 ~/.ssh/environment
         This file is read into the environment at login (if it exists).
         It can only contain empty lines, comment lines (that start with
         ‘#’), and assignment lines of the form name=value.  The file
         should be writable only by the user; it need not be readable by
         anyone else.  Environment processing is disabled by default and
         is controlled via the PermitUserEnvironment option.


답변

sshd_config에서는 다음과 같이 설정할 수 있습니다.

ForceCommand /usr/local/bin/setsshenv

여기서 setsshenv다음과 같은 :

#!/bin/bash
export VAR1=value1
export VAR2=value2
...
exec $SSH_ORIGINAL_COMMAND

사용자의 ~ / .ssh / environment 스크립트를 읽기 전이나 후에 실행할 것인지 확실하지 않습니다.


답변