1
0
Fork 0
mirror of synced 2024-11-30 03:05:35 -05:00
zimfw/modules/ssh/init.zsh

35 lines
742 B
Bash
Raw Normal View History

2015-12-15 00:12:17 -05:00
#
# sets up ssh-agent
#
# don't do anything unless we can actually use ssh-agent
2015-12-19 09:48:29 -05:00
if (( ! ${+commands[ssh-agent]} )); then
2015-12-15 00:12:17 -05:00
return 1
fi
ssh-add -l &>/dev/null
if (( ? == 2 )); then
# Unable to contact the authentication agent
2015-12-15 00:12:17 -05:00
# Load stored agent connection info
local ssh_env="${HOME}/.ssh-agent"
[[ -r ${ssh_env} ]] && source ${ssh_env} >/dev/null
2015-12-15 00:12:17 -05:00
ssh-add -l &>/dev/null
if (( ? == 2 )); then
# Start agent and store agent connection info
(umask 066; ssh-agent >! ${ssh_env})
source ${ssh_env} >/dev/null
2015-12-15 00:12:17 -05:00
fi
fi
# Load identities
ssh-add -l &>/dev/null
if (( ? == 1 )); then
2015-12-15 00:12:17 -05:00
if (( ${#zssh_ids} > 0 )); then
ssh-add "${HOME}/.ssh/${^zssh_ids[@]}" 2> /dev/null
else
ssh-add 2> /dev/null
fi
fi