do shell script with Password

I am backing up files on our school server using rsync. This is done remotely using the following:

ssh filedirector@10.48.209.253
myPassword
rsync --recursive --archive --update --delete --verbose /gecko/ /Volumes/ServerBak/backups

I know how to concatenate command lines so I can pass them all with a single “do shell script” invocation but, the problem is waiting for and then submitting the user password. Can I do this with Applescript? That is, pass the first command line, then wait for the password query, submit the password, wait for confirmation, and lastly pass the rsync command?

It would be nice to have an applescript that I could run from iCal every night.

Your better off using DSA Keys which is a feature of OpenSSH

Check out this article for a better walkthrough than I could give :slight_smile:

http://www.oreillynet.com/pub/a/wireless/2001/11/20/secure_webcam.html

Hoping I can revive this topic…

I’ve got a similar ssh situation to the op, I’m trying to automate a ssh login to a server outside of China, port-forwarding through the tunnel and then feeding a URL to a web browser set to those ports. The O’Reilly solution seems to be a DSA key with no passphrase, but if possible I’d like to keep the passphrase as an added layer of security (and I’ll be at the computer when I’m using this, anyway). When I run my script, Applescript seems aware that the shell is asking for something, as it comes up with an error message about three failed tries after a little while. Can anyone tell me how I can make the script request the passphrase?

Thanks!
Eric

This works on my local network. Just insert your username and the ip address, and adjust the delay to however long is appropriate for your situation.

set tempVar to display dialog "Please enter your password" default answer "" with hidden answer
set thepassword to text returned of tempVar

tell application "Terminal"
	activate
end tell
tell application "System Events"
	tell process "Terminal"
		keystroke "ssh username@ip address"
		keystroke return
		delay 5
		keystroke thepassword
		keystroke return
	end tell
end tell