Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #!/bin/bash
  2. # Script to fix the SSH agent environment variable after reconnecting to a running screen session.
  3. # Usage: *source* this script (don't just execute).
  4. # For example, if you store it at ~/screen-ssh-agent-fix.sh, create this alias to have it available easily:
  5. # alias screenfix='source ~/screen-ssh-agent-fix.sh'
  6.  
  7. echo "Updating ssh-agent socket environment.."
  8. echo "Current value: $SSH_AUTH_SOCK"
  9.  
  10. 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)
  11.  
  12. if [ $? -gt 0 ]; then
  13. echo "ERROR!"
  14. exit $?
  15. fi
  16.  
  17. echo "New value: $SSH_AUTH_SOCK"
  18. echo "All done!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement