]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | # ssh-agent.sh is a sh/bash/zsh compatible script sourced from /etc/profile.d/ | |
3 | # at user login. It reads configuration from /etc/ssh/ssh-agent.conf | |
4 | # or ~/.ssh/ssh-agent.conf if any exist and, depending on settings | |
5 | # in configuration file, runs ssh-agent with given options at first user login, | |
6 | # exports SSH_AGENT_PID SSH_AUTH_SOCK environment variables to all login | |
7 | # sessions. If ssh-agent is already started for given user, script exports only | |
8 | # SSH_AGENT_PID SSH_AUTH_SOCK to new user's login session. | |
9 | ||
10 | [ -f /etc/ssh/ssh-agent.conf ] && SSH_AGENT_CONF="/etc/ssh/ssh-agent.conf" | |
11 | [ -f "${HOME}/.ssh/ssh-agent.conf" ] && SSH_AGENT_CONF="${HOME}/.ssh/ssh-agent.conf" | |
12 | if [ -s "$SSH_AGENT_CONF" ] ; then | |
13 | . "$SSH_AGENT_CONF" || : | |
14 | if [ "$ssh_agent_enable" = "yes" -o "$ssh_agent_enable" = "YES" ] ; then | |
15 | SSH_AGENT_DATA="${HOME}/.ssh/SSH-AGENT-DATA" | |
16 | if [ -s "$SSH_AGENT_DATA" ] ; then | |
17 | . "$SSH_AGENT_DATA" > /dev/null | |
18 | if [ "$(ps uhp "$SSH_AGENT_PID" 2>/dev/null | awk '$1 ~ ENVIRON["USER"] {print $11}')" != "ssh-agent" ] ; then | |
19 | ssh-agent $ssh_agent_flags > "$SSH_AGENT_DATA" | |
20 | . "$SSH_AGENT_DATA" > /dev/null | |
21 | fi | |
22 | else | |
23 | ssh-agent $ssh_agent_flags > "$SSH_AGENT_DATA" | |
24 | . "$SSH_AGENT_DATA" > /dev/null | |
25 | fi | |
26 | fi | |
27 | fi | |
28 |