Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: A few lines in .zshenv (re ssh-agent) disable scp and rsync?



On 2011-06-27 03:36:23 -0400, Benjamin R. Haskell wrote:
> You shouldn't put anything that echoes output to the terminal in a login
> profile.  That should be saved for interactive startup scripts.
> 
> In Zsh's case, that means you can solve this by simply moving those lines
> from .zshenv (which gets run for all shells, including those which don't
> accept input interactively) to .zshrc (which is only run for interactive
> shells).

Or this can be tested. For instance, I have:

[[ -o interactive ]] && echo 'zshenv...'

> So, you could also solve this by conditioning all of the ssh-agent actions
> on whether a terminal is connected:
> 
> # if stdin is a terminal (unnecessary in .zshrc)
> if [[ -t 0 ]] ; then
> 	# kill the ssh-agent on exit
> 	trap '[[ -n "$SSH_AGENT_PID" ]] && eval `ssh-agent -k`' 0
> 	# start the ssh-agent if not already started
> 	[[ -z "$SSH_AGENT_PID" ]] && eval `ssh-agent`
> 	# add identities to the agent
> 	ssh-add
> fi

It depends whether the user wants this to be executed with:

ssh -t <host> <command>

BTW, I think that on-demand ssh-add is better (i.e. running it just
before the ssh/scp/...).

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)



Messages sorted by: Reverse Date, Date, Thread, Author