Setting Environment variables for ssh sessions.

Hey,

So I've got several environment variables that I want to have set when I open up an Xterm.

I've added them to my .bashrc file, and when I open up an Xterm on my machine directly, things seem to work out just fine.

But when I ssh into my machine with the same username and password, my environement variables don't seem to get set!!???

What's going on here? How can I fix it?

Thanks

B

Imac G3 400mhz, Mac OS X (10.4)

Posted on Oct 5, 2006 11:32 AM

Reply
2 replies

Oct 5, 2006 2:53 PM in response to Bill Gray2

Hi Bill,
You have a home directory on the remote machine, right? The shell you are using in the secure shell session is the one on the remote machine so you put the stuff in the a shell startup script in your home directory on that machine.

The shell you use when login via secure shell will almost certainly be a "login shell". That tends to be the first shell you open after you login to a machine. That shell will not read the ~/.bashrc but will read a script named ~/.bash_profile. If you already have a ~/.bashrc with the correct stuff in it, you can simply put the following line in your ~/.bash_profile:

. ~/.bashrc

That will cause the commands in the ~/.bashrc file to be executed when the shell sources the ~/.bash_profile.

~/.bash_profile is not the only name you can give this script. Except for a good working definition of a login shell, a thorough discussion of these scripts and their role in shell startup can be found in the INVOCATION section of the bash(1) man page.
--
Gary
~~~~
Serfs up!
-- Spartacus

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Setting Environment variables for ssh sessions.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.