SSH Script - Need a 'lil help chaps!

Hello everyone. I’ve been trying to develop a script which turns on the “Remote Login” part of whole SSH process. I’ve attempted one way, using GUI editing, but run into a problem actually CLICKING the check box in the Sharing Preference pane.


tell application "System Preferences"
	activate
end tell

tell application "System Events"
	tell process "System Preferences"
		click menu item "Sharing" of menu "View" of menu bar 1
		delay 3
		tell window "Sharing"
			tell tab group 1
				click radio button "Services"
				delay 2
				-- need help to edit this following line here!
				-- select text "Remote Login" --
				delay 2
				click button "Start"
			end tell
		end tell
	end tell
end tell

ignoring application responses
	tell application "System Preferences" to quit
end ignoring

MORE IMPORTANTLY, is this other way. I know for a fact that SSH Remote Login can be enabled through accessing/.editing/enabling a file, possibly in /ect/ssh folder. Is there a way to enable Remote Login, just by enabling some file? (possibly ect/ssh/ssh_config?) Thanks for you help in advance.

  • Deepee

My advice: Don’t use GUI scripting at all.

do shell script "launchctl -w load /System/Library/LaunchDaemons/ssh.plist" with administrator privileges

Thanks for the replys! First off, the GUI works perfectly, nice job. However, the ultimate goal IS to do it without GUI editing, and the script above this seems to be attemtping that, but i get the following applescript error: "launchctl: unknown subcommand “-w”. Removing -w from the script gets the error that it found nothing to load. Maning “launchctl” in terminal, I find that I have two suboptions:

          -w       Remove the disabled key and write the configuration
                   files back out to disk.

          -F       Force the loading of the plist. Ignore the Disabled
                   key.

The -F modifyer doesn’t seem to work in applescript, which gives me the unrecogniztion error.

I’m not sure why I’m getting the error, any ideas? Thanks again for your time.

Awsome, that last one appeared to ACTIVATE SSH, but does not activate Remote Login. This is probably safter, but is it achieving the same goal? Lastly, how do I turn it off?

Perfect. Got one last question for ya. How do I find the address of the SSH to connect to once it has been activated on the other computer and convert it to a variable. IE: whomever@ip address (i believe that is the format).