-
-
Save HelioCampos/594e119c6cc6a72f816c4000059d7568 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -n "$SSH_AUTH_SOCK" ] && netstat -nlpx 2> /dev/null | awk '{print $NF}' | grep -qF "$SSH_AUTH_SOCK"; then | |
echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" > /tmp/ssh-agent$UID | |
if [ -n "$SSH_AGENT_PID" ]; then | |
echo "export SSH_AGENT_PID=$SSH_AGENT_PID" >> /tmp/ssh-agent$UID | |
elif [ -n "$GNOME_KEYRING_PID" ]; then | |
echo "export GNOME_KEYRING_SOCKET=$GNOME_KEYRING_SOCKET" >> /tmp/ssh-agent$UID | |
echo "export GNOME_KEYRING_PID=$GNOME_KEYRING_PID" >> /tmp/ssh-agent$UID | |
fi | |
else | |
SSH_AUTH_SOCK= | |
id1=$HOME/.ssh/identity | |
id2=$HOME/.ssh/id_dsa | |
id3=$HOME/.ssh/id_rsa | |
if [ -f $id1 -o -f $id2 -o -f $id3 ]; then | |
process= | |
if [ -x /usr/bin/ssh-agent ]; then | |
[ -f /tmp/ssh-agent$UID ] && source /tmp/ssh-agent$UID > /dev/null | |
export GNOME_KEYRING_SOCKET= | |
export GNOME_KEYRING_PID= | |
if [ -n "$SSH_AGENT_PID" ]; then | |
process=$(ps -p "$SSH_AGENT_PID" -o comm= 2> /dev/null) | |
fi | |
if [ "$process" != "ssh-agent" ]; then | |
ssh-agent -s > /tmp/ssh-agent$UID | |
source /tmp/ssh-agent$UID | |
ssh-add < /dev/null | |
fi | |
elif which gnome-keyring-daemon > /dev/null 3>&1; then | |
[ -f /tmp/ssh-agent$UID ] && source /tmp/ssh-agent$UID > /dev/null | |
export SSH_AGENT_PID= | |
if [ -n "$GNOME_KEYRING_PID" ]; then | |
process=$(ps -p "$GNOME_KEYRING_PID" -o comm= 2> /dev/null) | |
fi | |
if [ "$process" != "gnome-keyring-daemon" ]; then | |
gnome-keyring-daemon --start > /tmp/ssh-agent$UID | |
source /tmp/ssh-agent$UID | |
export GNOME_KEYRING_SOCKET SSH_AUTH_SOCK GNOME_KEYRING_PID | |
fi | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment