Skip to content

Instantly share code, notes, and snippets.

@piger
Created September 29, 2013 14:41
Show Gist options
  • Save piger/6753069 to your computer and use it in GitHub Desktop.
Save piger/6753069 to your computer and use it in GitHub Desktop.
Lazy SSH Agent notification utility for OS X.
#!/bin/sh
# Lazy SSH Agent notification utility for OS X.
#
# Instead of asking the user for the confirmation to use a ssh key this script
# will just show a notification in Notification Center.
#
# Install as /usr/libexec/ssh-askpass
#
# Requires: terminal-notifier - https://github.com/alloy/terminal-notifier
set -e
TERMINAL_NOTIFIER="/Users/sand/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier"
MESSAGE=$(echo $@ | perl -e '@m=<>; $key = $1 if $m[0] =~ m@(/[^\?]+)@m; $fp = $1 if $m[0] =~ m/fingerprint (.*)/m; print "$key: $fp";')
$TERMINAL_NOTIFIER -activate "com.apple.Terminal" -title "SSH Agent is using a key" -message "$MESSAGE" > /dev/null 2>&1 &
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment