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

Advertisement

15 thoughts on “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.

  6. [...] Only problem was I hadn’t set up my RSA keys so Git was still asking for my password. Aptana requires a little program called ssh-askpass. After a little Googling I found a scary looking script that was specific to mercurial, but works for pretty much anything aparently. [...]

  7. [...] 쪽에서는 SSH-AskPass 스크립트를 만들고 다음과 같은 작업을 해준다. ssh-askpass on OSX 10.5 문서를 참고해서 /usr/libexec 위치 아래에 ssh-askpass 파일을 만들어 [...]

  8. bob says:

    works on snowleopard…

  9. [...] to play nice in scripts, which is why we need a quick shell-script, ssh-askpass (which I got from here) to handle [...]

  10. [...] 但是系统上并没有找到此文件,最终在此处找到答案: [...]

  11. Mark Carver says:

    I have drastically updated this script. Please see:

    https://github.com/markcarver/mac-ssh-askpass

  12. rory says:

    dude, thanks! saved my ass

  13. Saran Babu says:

    If you are using MercurialEclipse or a single Login (credential) you can hard-code the password in the ssh-askpass file itself,

    eg:

    ! /bin/sh
    echo “your password” | sed -e ‘s/^text returned://’ -e ‘s/, button returned:.*$//’

  14. Jeff Vandehey says:

    This was an awesome fix! I use ClusterIT to manage a cluster of linux nodes. After my 10.7 upgrade, I was missing ‘known-hosts’ for the linux nodes. Your script prompted me to add, and now dsh is working again. Excellent!

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,397 other followers