View Full Version : AppleScripting Terminal to SSH: the bloody password

09-27-2004, 11:00 AM
The only AppleScript routine I have at my fingertips for having an AppleScript-capable application cause Terminal to make an SSH connection to our server is using

do script "ssh 192.168.xx.yyy" in Window 1
wait 4
do script "thePassword" in Window 1

which works except that sometimes on our oft-sludgy network the Terminal hasn't succeeded in knocking on Server's door and getting the "Password?" prompt by the time the next AppleScript line executes, and when that happens the Server's password appears in the Terminal window, visible to the user and plain as daylight.

Under MacOS 9, where I'm doing it via the program MacSSH PPC, I create the connection via AppleScript step 'getURL ssh UserName:thePassword@192.168.xx.yy' and no matter what happens the password never appears in plain text in the window.

I've tried 'do script ssh UserName:thePassword@192.168.xx.yy' under OS X but that doesn't fly.

Advice? Is there some way I can turn 'echo off' until I've made a connection, maybe?

09-27-2004, 11:04 AM
one possibility: setup passwordless SSH.


09-27-2004, 01:14 PM
Wouldn't the tendency/ability of people to see the key being sent = an ability to establish the same connection manually sending the same lines they say onscreen?

09-27-2004, 05:14 PM
Never mind. When all else fails, try the obvious and have the Mac do what you'd do yourself

If contents of window 1 contains "password" then
{do script "thePassword" and then do other stuff}
display dialog "Connection failed" buttons ["damn"]
End If

09-27-2004, 05:50 PM
You might want to place the test into a wait loop to exit when the word 'password' appears or it times out.