Skip to content

Instantly share code, notes, and snippets.

@mapi
Created July 9, 2011 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mapi/1073843 to your computer and use it in GitHub Desktop.
Save mapi/1073843 to your computer and use it in GitHub Desktop.
#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