ssh : remote command execution doesn't work for modifying env variables
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Ubuntu Breezy, Red Hat enterprise linux 3
Posts: 8
Rep:
ssh : remote command execution doesn't work for modifying env variables
Hello,
I m trying to open an ssh connection on a server and immediatly execute a command after bash login.
I set up the rsa authentication to avoid interactive passwords issues.
I'd like to customize the prompt of the shell on the server, WITHOUT modifying anything on it (specially .bashrc or .bash_profile)
--norc Do not read and execute the system wide initialization file
/etc/bash.bashrc and the personal initialization file ~/.bashrc
if the shell is interactive. This option is on by default if
the shell is invoked as sh.
Yes... bash --login (without --norc) will always read in configuration files. Specifying the export afterward will set the environment variable when bash EXITS.
Well, my suggestion would only temporarily alter the env for that run of that ssh call; ie when the process exits, the env goes away and in any case no other process will be affected unless they source the script also.
Normal programming practice.
Distribution: Ubuntu Breezy, Red Hat enterprise linux 3
Posts: 8
Original Poster
Rep:
Good points, thanks for the attention guys ;-)
Crism01 I agree with you regarding the way to think about the problem, It's exactly what I'm trying to do, but again your script has to be stored on the server side (no ?), what I'd like to avoid ... and to be run automatically after bash launch.
German , It could be a solution but I don't want to prevent the environmnent to be customized except for specific variables. With your solution the account aliases and variables will be skiped ...
I think we need more info on eactly WHAT you are trying to do and WHY....
After all, if you are allowed to login and run stuff on the remote box, you are allowed to add scripts to it... or maybe just manually type in any changes you want???
Distribution: Ubuntu Breezy, Red Hat enterprise linux 3
Posts: 8
Original Poster
Rep:
You're right it could be a solution to deploy some configuration files or scripts on the remote box, the problem is that I ve got about 9 000 of them ...
What I m doing is building a centralized gateway, mandatory to access these thousands of servers (to control and grant accesses). You connect to the central gateway, choose the host you want to connect and then your connection is forwarded to the remote server (exactly like you would do directly).
BUT after opening the connection between the gateway and the remote box I would like to modify an environmnent variable 'on the fly' for the bash session...
Am I a little more clear ? I recognize the issue is a bit particular and difficult to realise.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.