ssh into machine using applescript

I’m trying to be able to SSH into computers on our network and perform tasks via applescript.

so far I’ve got it to connect, but I can’t get it to be able to enter in the password - I’ve tried the keystroke command, but it doesn’t like that.

heres what I’ve got


tell application "Terminal"
	do script "ssh root@white-macbook.local"
	
	
end tell

Not much i know, but can anyone suggest how I’d be able to get the password entered?

I’ve also tried

tell application "Terminal"
	do script "ssh root@white-macbook.local"
	password "apple"
	
end tell

and

tell application "Terminal"
	do script "ssh root@white-macbook.local"
	keystroke "apple"
	
end tell

If your not oppossed to it I would recommend using DSA Keys for doing your SSH authorization rather then trying to feed it a password.

  1. On your client machine generate your key pair
ssh-keygen -d

2)Press [Return] thrice to accept defaults.

  1. Copy key to remote .ssh directory
scp ~/.ssh/id_dsa.pub <client name>:.ssh/authorized_keys2

From there you should be able to ssh into the client machine without needing a password.