Wednesday, January 31, 2018

Re: at/batch(1) and ssh-agent(1) environment variables

On Wed, 31 Jan 2018 11:39:23 +0100, Erwin Geerdink wrote:

> at/batch(1) appears to not retain SSH_AUTH_SOCK and SSH_AGENT_PID
> environment variables when commands are executed. According to the man
> page:
>
> "(...) The working directory, the environment (except for the variables
> TERM, TERMCAP, DISPLAY, and _), and the umask are retained from the
> time of invocation. An at or batch command invoked from a su(1) shell
> will retain the current user ID."
>
> Why are those variables not preserved?

Because at/batch jobs are by their very nature non-interactive so
it doesn't make sense to preserve environment variables that are
specific to an interactive login.

If you wish to preserve those variables, you can do so explicitly.
For example:

echo "export SSH_AGENT_PID=$SSH_AGENT_PID; export SSH_AUTH_SOCK=$SSH_AUTH_SOCK; env" | at now

- todd

No comments:

Post a Comment