Skip to content

Instantly share code, notes, and snippets.

@mapi mapi/gist:1073843
Created Jul 9, 2011

Embed
What would you like to do?
#screenでssh-agentを使いまわす
function ssh-init {
local SSH_AUTH_SOCK_DIR="$HOME/.tmp/ssh-agent"
#ここは初めてか?
if [ ! -d ${SSH_AUTH_SOCK_DIR} ]; then
mkdir -p ${SSH_AUTH_SOCK_DIR}
chmod 700 ${SSH_AUTH_SOCK_DIR}
fi
#ソケット作る
AGENT="${SSH_AUTH_SOCK_DIR}/`hostname`"
if [ -S "${AGENT}" ]; then
export SSH_AUTH_SOCK=${AGENT}
elif [ ! -L "${SSH_AUTH_SOCK}" ]; then
ln -snf "${SSH_AUTH_SOCK}" ${AGENT} && export SSH_AUTH_SOCK=${AGENT}
elif [ ! -S "${SSH_AUTH_SOCK}" ]; then
echo "no ssh-agent"
exit 1
fi
ssh-add ${1}
#それkeychainで出来るよ
#http://manpages.ubuntu.com/manpages/oneiric/en/man1/keychain.1.html
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.