Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Script to fix the SSH agent environment variable after reconnecting to a running screen session.
- # Usage: *source* this script (don't just execute).
- # For example, if you store it at ~/screen-ssh-agent-fix.sh, create this alias to have it available easily:
- # alias screenfix='source ~/screen-ssh-agent-fix.sh'
- echo "Updating ssh-agent socket environment.."
- echo "Current value: $SSH_AUTH_SOCK"
- export SSH_AUTH_SOCK=$(find /tmp/ssh-* -user `whoami` -name agent\* -printf '%T@ %p\n' 2>/dev/null | sort -k 1nr | sed 's/^[^ ]* //' | head -n 1)
- if [ $? -gt 0 ]; then
- echo "ERROR!"
- exit $?
- fi
- echo "New value: $SSH_AUTH_SOCK"
- echo "All done!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement