Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
markhalliwell committed Sep 15, 2011
0 parents commit 6ed0d79
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
19 changes: 19 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
# Script: INSTALL
# Author: Mark Carver
# Created: 2011-09-14
# Copyright (c) 2011 Beyond Eden Development, LLC. All rights reserved.

if [[ $EUID -ne 0 ]]; then
echo "ERROR: This installation must be run as 'root'. Try using the command \`sudo INSTALL\`." &>/dev/stderr;
exit 1
else
sshaskpass='/usr/libexec/ssh-askpass';
if [[ $(cp ./ssh-askpass ${sshaskpass}) -eq 0 ]] && [[ $(chmod +x ${sshaskpass}) -eq 0 ]]; then
echo "Successfully installed '${sshaskpass}'.";
${sshaskpass} "$(printf "Testing ssh-askpass!\n\nNOTE: Test will output to terminal!")";
exit $?;
else
echo "Failed to install '${sshaskpass}'. Check to make sure you have write abilities for '$(dirname ${sshaskpass}) and then try again." &>/dev/stderr; exit 1;
fi
fi
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ssh-askpass (for Mac OS X)

Author: Mark Carver
Created: 2011-09-14
Copyright (c) 2011 Beyond Eden Development, LLC. All rights reserved.

Based from author: Joseph Mocker, Sun Microsystems
[http://blogs.oracle.com/mock/entry/and\_now\_chicken\_of\_the](http://blogs.oracle.com/mock/entry/and\_now\_chicken\_of\_the)

---

# Usage
Install this script as root
> `sudo ./INSTALL`
# Notes
If you plan on manually installing this script, please note that you will have to set the following variable for SSH to recognize where the script is located:

> `export SSH_ASKPASS="/path/to/ssh-askpass"`
32 changes: 32 additions & 0 deletions ssh-askpass
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# Script: ssh-askpass
# Author: Mark Carver
# Created: 2011-09-14
# Copyright (c) 2011 Beyond Eden Development, LLC. All rights reserved.

# A ssh-askpass command for Mac OS X
# Based from author: Joseph Mocker, Sun Microsystems
# http://blogs.oracle.com/mock/entry/and_now_chicken_of_the

# To use this script:
# Install this script running INSTALL as root
#
# If you plan on manually installing this script, please note that you will have
# to set the following variable for SSH to recognize where the script is located:
# export SSH_ASKPASS="/path/to/ssh-askpass"

TITLE="${SSH_ASKPASS_TITLE:-SSH}";
TEXT="$(whoami)'s password:";
IFS=$(printf "\n");
CODE=("on GetCurrentApp()");
CODE=(${CODE[*]} "tell application \"System Events\" to get short name of first process whose frontmost is true");
CODE=(${CODE[*]} "end GetCurrentApp");
CODE=(${CODE[*]} "tell application GetCurrentApp()");
CODE=(${CODE[*]} "display dialog \"${@:-$TEXT}\" default answer \"\" with title \"${TITLE}\" with icon caution with hidden answer");
CODE=(${CODE[*]} "text returned of result");
CODE=(${CODE[*]} "end tell");
SCRIPT="/usr/bin/osascript"
for LINE in ${CODE[*]}; do
SCRIPT="${SCRIPT} -e $(printf "%q" "${LINE}")";
done;
eval "${SCRIPT}";

0 comments on commit 6ed0d79

Please sign in to comment.