ssh-askpass (for Mac OS X)
Note: this project has been deprecated in favor of the brew package: https://github.com/theseal/ssh-askpass
brew tap theseal/ssh-askpass
brew install ssh-askpass
Author: Mark Carver
Created: 2011-09-14
Licensed under GPL 3.0
Based off script from author: Joseph Mocker, Sun Microsystems http://blogs.oracle.com/mock/entry/and_now_chicken_of_the
If you've gotten this error:
remote: ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
Then you probably need this script. Mac OS X does not prompt for a password outside of Terminal when connecting via SSH (for security reasons). This script grants any application the ability to prompt the user for a password via an AppleScript dialog.
Usage
- You can install this script using the
INSTALL
file included with the download (easiest/automatic)
- Open Terminal
/Applications/Utilities/Terminal.app
- Type
sudo``
(with the space at the end)- Drag the
INSTALL
file ontoTerminal
and pressreturn
- Enter your password
- You can install this script manually:
- Copy the source code located below
- Open Terminal
/Applications/Utilities/Terminal.app
- Type
sudo vi /usr/libexec/ssh-askpass
- Enter your password
- Type
i
to go into edit mode- Press
⌘v
to paste the code- Press
esc
to go out of edit mode- Type
:
thenw
and pressreturn
to write the file- Type
:
thenx
and pressreturn
to exit vi- Type
sudo chmod +rx /usr/libexec/ssh-askpass
to make the script executable- Test the script! Type
/usr/libexec/ssh-askpass
NOTE: You must run as
root
or precede the commands withsudo
when usingINSTALL
orvi
. The directory/usr/libexec
is owned byroot
.
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"
Source
#!/bin/bash
# Script: ssh-askpass
# Author: Mark Carver
# Created: 2011-09-14
# Licensed under GPL 3.0
# 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[*]} "activate");
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}";