ssh-askpass on OSX 10.5

I’ve been playing with NetBeans 6.7M3 and the latest Mercurial plugin and found that I couldn’t push to a remote repository via ssh. All netbeans would return was:

Mercurial Push
--------------
INFO Pushing To: ssh://pmount@lego.office.gameaccount.com/hg/ga4Partner ...
ERROR Command failed:
Command: [/usr/local/bin/hg, outgoing, -v, --template=rev:{rev}\nauth:{author}\ndesc:{desc}\ndate:{date|hgdate}\nid:{node|short}\n\nendCS:\n, --repository, /Users/peter/dev/gameaccount/maven/ga4Partner, ssh://pmount@lego.office.gameaccount.com/hg/ga4Partner]
Output: [running ssh pmount@lego.office.gameaccount.com “hg -R hg/ga4Partner serve --stdio”, remote: ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory, remote: Host key verification failed., abort: no suitable response from remote hg!]
INFO: End of Mercurial Push

Here the remote server is trying to prompt for the login password but fails because OSX 10.5 does not have the ssk-askpass command.

After some searching on the net (ok Google who else) I found Mercurial Push from IntelliJ where someone had a similar position with IntelliJ. By creating the following script mercurial in NB6.7M3 works flawlessly:

sabrina:~ peter$ sudo vi /usr/libexec/ssh-askpass
#! /bin/sh  

#
# An SSH_ASKPASS command for MacOS X
#
# Author: Joseph Mocker, Sun Microsystems  

#
# To use this script:
#     setenv SSH_ASKPASS "macos-askpass"
#     setenv DISPLAY ":0"
#  

TITLE=${MACOS_ASKPASS_TITLE:-"SSH"}  

DIALOG="display dialog \"$@\" default answer \"\" with title \"$TITLE\""
DIALOG="$DIALOG with icon caution with hidden answer"  

result=`osascript -e 'tell application "Finder"' -e "activate"  -e "$DIALOG" -e 'end tell'`  

if [ "$result" = "" ]; then
    exit 1
else
    echo "$result" | sed -e 's/^text returned://' -e 's/, button returned:.*$//'
    exit 0
fi  

sabrina:~ peter$ sudo chmod +x /usr/libexec/ssh-askpass

About petermount1
Java nut working in the online gaming industry, prolific Open Source Java developer and member of the XSF Technical Review team

5 Responses to ssh-askpass on OSX 10.5

  1. Yaroslav says:

    Copy-paste of this code fails because of fancy quotes.

  2. Peter Mount says:

    Thanks, I'll fix the article shortly. It's a problem with using MacJournal in the past where it keeps using Unicode quotes instead of ASCII ones – that and the horrible html it generates.

  3. macsebi says:

    THANK YOU FOR THIS!!!!

  4. Yoneh says:

    This fails if you have any 32-bit extension on 64-bit Snow Leopard.

    On line 20, you should rather use “arch -i386 osascript …”

    The source of my 64-bit problem was Adobe’s software,
    so I decided to use “arch -i386 osascript …”.

    There are another solutions for this specific Adobe’s problem:
    http://kb2.adobe.com/cps/516/cpsid_51615.html

  5. petermount1 says:

    Yes, when I originally wrote this Snow Leopard wasn’t available and so far have not yet been able to upgrade due to a couple of software dependencies that don’t work with it.

    Hopefully by the end of the month I’ll have sorted those two out so would have hit this problem myself.

    Thanks for the tip.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>