1

As far as i know upon SSH login the following files are executed

[SERVER] /etc/environment

[Client] ~/.ssh/environment
-> can be locally overriden by "SSH_ENV" environment variable
-> will override Host=>SendEnv in local ~/.ssh/config
-> will be filtered by "AcceptEnv" directive(s) in remote /etc/ssh/sshd_config
-> will NOT be used if "PermitUserEnvironment no" in remote /etc/ssh/sshd_config

[SERVER] /etc/ssh/sshrc         
-> will NOT get executed if "ForceCommand" exists in remote /etc/ssh/sshd_config
-> will NOT get executed if local ~/.ssh/rc exists
-> can be overriden by "ForceCommand" (kind of)

[Client] ~/.ssh/rc              
-> will NOT get executed if "ForceCommand" is configured
-> can be overriden by local "???" environment variable?

Question

How can i force the execution of a script on the server but still allow the client to use his ~/.ssh/rc ?

Bonus question

Is it possible to override the local ~/.ssh/rc location using an environment variable? If yes which one?

1 Answers1

3

The solution seems to be to evaluate the

SSH_ORIGINAL_COMMAND

environment variable that gets set to the command in the client's ~/.ssh/rc inside the script configured as ForceCommand.

I found this possible solution in this answer.


Remaining: Is there a way to override the ~/.ssh/rc location using an environment variable?

guettli
  • 1,765