Sometimes it is necessary to define an environment variable when starting a PSMP session.
Steps
Below are two possible methods to do this:
- Specify the environment variable in the ClientApp parameter of the PSMP-SSH Connection Component.
- On the target machine add the following line to the sshd.config: AcceptEnv <ENV_VARIABLE>, where <ENV_VARIABLE> is the name of the environment variable. Make sure to restart the sshd service (service sshd restart).
- In PVWA got to Administration > options > Connection Components > PSMP-SSH > Target Settings > ClientApp
- Add the environment variable to the ClientApp value using -o SetEnv for example:
{PSPComponentsFolder}/ssh [-{PSMProtocol}] [-p {Port}] -o "SetEnv TEST_ONE=test1" [-L {PSMTunnelRandomPort}:127.0.0.1:{PSMTunnelTargetPort}] {Username}@{Address}
-
- Save the changes and either restart the PSMP service or wait for the configuration update (usually 10 minutes).
NOTES :
- This only works with the ssh client in PSMP. It will not work with the plink client.
- The change to the ClientApp parameter can be done as an override of the Target Settings for a specific platform.
- To make this dynamic per account it is possible to add a parameter to the ClientApp value instead of a hard-codded value for the environment variable. For example add a parameter to the platform called EnvValue and change the ClientApp value to:
{PSPComponentsFolder}/ssh [-{PSMProtocol}] [-p {Port}] -o "SetEnv TEST_ONE={ EnvValue}" [-L {PSMTunnelRandomPort}:127.0.0.1:{PSMTunnelTargetPort}] {Username}@{Address}
- Open the PSMP connection as a shell command in a terminal using -t and export. For example:
ssh -t VaultUser@TargetUser@TargetAddress@PSMPaddress 'export TEST_ONE=test1; bash'
On the target machine make sure to add the following line to the sshd.config: AcceptEnv TEST_ONE. Make sure to restart the sshd service (service sshd restart).