Created
March 1, 2015 19:01
-
-
Save gibwar/074a6c1a8a28694a8577 to your computer and use it in GitHub Desktop.
ssh-askpass for OSX 10.10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Save as /usr/libexec/ssh-askpass or somewhere else you control and set the | |
# SSH_ASKPASS environment variable to the location of this script. | |
# chmod a+rx /usr/libexec/ssh-askpass or | |
# chmod +x ~/wherever/you/saved | |
# NOTE: This is for OS X 10.10 only and shouldn't work on previous OS X. The | |
# format returned from osascript changed from "text returned:blah, button | |
# returned:OK" to "button returned:OK, text returned:blah". This script | |
# simply cuts on the : and returns the third field. | |
script=" | |
tell application \"System Events\" | |
set myName to name of the first process whose frontmost is true | |
end tell | |
tell application myName | |
display dialog \"$@\" default answer \"\" with title \"SSH AskPass\" with icon caution with hidden answer | |
end tell | |
" | |
result=`osascript -e "$script"` | |
if [ "$result" = "" ]; then | |
exit 1 | |
else | |
echo "$result" | cut -d: -f3 | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment