Set Local variables in PSMP session

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
PAM Self-Hosted Articles
2 min read
L0 Member
No ratings
Sometimes it is necessary to define an environment variable when starting a PSMP session.

Steps

Below are two possible methods to do this:
 
  1. Specify the environment variable in the ClientApp parameter of the PSMP-SSH Connection Component.
    1. 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).
    2. In PVWA got to Administration > options > Connection Components > PSMP-SSH > Target Settings > ClientApp
    3. 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}
    1. 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}

 
  1. 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).

 
Rate this article:
  • 176 Views
  • 0 comments
  • 0 Likes
Article Dashboard
Version history
Last Updated:
‎01-09-2022 05:35 AM
Updated by: