Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: How to modify environment variables before executing a command

0 views
Skip to first unread message

Carson Gaspar

unread,
Dec 5, 2009, 4:42:38 AM12/5/09
to
Jim Rees wrote:

> Ssh has no problem exporting env vars, as you have discovered. Just put
> them in .ssh/environment. You are trying to do something bash-specific in
> your ssh config file:
>
> VAR1=$(date)
>
> That's not going to work. If you want to run bash code, you have to put it
> in a bash config file, not in an ssh config file.

That's not bash-specific, that's POSIX. The "probem" is that
.ssh/environment is not shell code, it's just a set of key/value pairs.
Read the man page, it will help ;-)

If you want something to happen in your SSH session, and don't want it
to happen during normal shells, why don't you just ask for it in your
remote command? e.g. instead of doing "ssh myserver mycmd" do "ssh
myserver 'source myconfig && mycmd'". Otherwise modify your shell config
as many other folks have said, making its execution conditional on its
environment.
_______________________________________________
openssh-unix-dev mailing list
openssh-...@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev

Pfaffel-Janser, Christian

unread,
Dec 6, 2009, 2:03:13 PM12/6/09
to
Hi,

You might want to use

~/.ssh/rc

See sshd(8) for details.

Christian

-----Original Message-----
From: openssh-unix-dev-bounces+christian.pfaffel-janser=sieme...@mindrot.org on behalf of Carson Gaspar
Sent: Sat 2009-12-05 10:42
To: openssh-...@mindrot.org
Subject: Re: How to modify environment variables before executing a command

Jim Rees wrote:

> Ssh has no problem exporting env vars, as you have discovered. Just put
> them in .ssh/environment. You are trying to do something bash-specific in
> your ssh config file:
>
> VAR1=$(date)
>
> That's not going to work. If you want to run bash code, you have to put it
> in a bash config file, not in an ssh config file.

That's not bash-specific, that's POSIX. The "probem" is that
.ssh/environment is not shell code, it's just a set of key/value pairs.
Read the man page, it will help ;-)

If you want something to happen in your SSH session, and don't want it
to happen during normal shells, why don't you just ask for it in your
remote command? e.g. instead of doing "ssh myserver mycmd" do "ssh
myserver 'source myconfig && mycmd'". Otherwise modify your shell config

as many other folks have said, making its ex sshd(8ecution conditional on its

0 new messages