Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to pass some parameters as part of my ssh connection that I can use to set custom variables for my login to do certain things or run certain scripts. How do you do this running Putty on Windows machine, connecting via SSH to a CentOS machine?

share|improve this question
up vote 4 down vote accepted

On the CentOS machine, create a file in your home directory named .bashrc and set your environmental variables in there. For example, the contents of the file can be:

export VARIABLE=foo

Here's some discussion of this:


Thanks for the clarification.

You can use the SendEnv and AcceptEnv options. This will allow environmental variables on the client to be passed to the server.

You will also need to change the server's sshd_config file to specify which environmental variables are accepted by the server. I'm not sure what you'll need to do with PuTTY to issue the SendEnv option, but that should get you started.

share|improve this answer
Yeah I know how to do that, but how can I pass variables over as part of my connection? – qodeninja Aug 15 '11 at 19:12
Edited to include the SendEnv and AcceptEnv suggestion. – cjc Aug 15 '11 at 19:32
Awesome! Thanks for the update!! – qodeninja Aug 16 '11 at 0:38

You could can modify PermitUserEnvironment in sshd.conf to allow processing of ~/.ssh/environment or "environment=" options on keys in ~/.ssh/authorized_keys.

The format of these two files differs. ~/.ssh/environment is lines of VARIABLBE=VALUE where in ~/.ssh/authorized_keys the environment option is environment="VARAIBLE=VALUE"

share|improve this answer
Ok I found where to change PermitUserEnv but how do I pass params? – qodeninja Aug 16 '11 at 0:43

I believe no one answered your question: how can you set environment variables in putty?

I found someone else who answered that and it is best demonstrated in this screenshot:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.