Skip to content

@bendavis78 /gist:5464209
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Shell script to use in a vagrant provisioning script to enable SSH agent forwarding
#!/bin/bash
echo "Setting up agent forwarding..."
mkdir -p /root/.ssh
chmod 0700 /root/.ssh
echo "Host *\n StrictHostKeyChecking no" >> /root/.ssh/config
chmod 0600 /root/.ssh/config
ppid=$PPID
found_auth_sock=""
while [[ $SSH_AUTH_SOCK == "" && $ppid != "1" ]]; do
f=`ls /tmp/ssh*/agent.$ppid 2>/dev/null`
if [[ -z "$f" ]]; then
ppid=`cat /proc/$ppid/status | grep PPid | awk '{print $2}'`
else
export SSH_AUTH_SOCK="$f"
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
fi
done
if [[ -z "$SSH_AUTH_SOCK" ]]; then
echo "Could not find running ssh agent.\n" 1>&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.