1

I'd like to be able to log in my computer through Apple Remote Desktop (SSH) by running a script while the remote computer is running the loginWindow.

An ideal script would automate the process of selecting the "Other..." tile (see pic1), and then insert username and password fields, and finally press the submit button (see pic2).

enter image description here

enter image description here

Based on what I've found on the web, I came up with the following solution which meant to perform the last 2 steps only(2 and 3) while I'm already pressed the "Other..." tile manually and I'm on the second screen :

set username_ to "myself"
set password_ to "mypass"

tell application "System Events"
tell process "SecurityAgent"
get properties
    if exists (text field 1 of window 1) then
        set value of text field 1 of window 1 to username_
        set value of text field 2 of window 1 to password_
    end if
    click button "Allow" of group 1 of window 1
end tell
end tell

however, I'm getting the following error : /tmp/my.scpt:119:129: execution error: An error of type -610 has occurred. (-610)

Perhaps anybody can help me fix my script, or how to debug it properly ?

5
  • Couple things...ARD and SSH are two totally different things and if I’m not mistaken, for AppleScript to run, it must do so under a logged in account. Since you’re not logged in, it wont run. Finally, saving credentials in plain text is definitely not a good idea.
    – Allan
    Jun 4, 2020 at 0:49
  • Ok, so if I need to run my script under logged-in account, so it can be done from lock screen ? I just added new authorizationRight to the login flow and I want an automated test to run successful login on every build to see that I haven't broken anything... Here's another option that will better simulate my test scenario, perhaps do you know how does fast-user-switching work in macOS and whether I can login to different account from lock screen ?
    – Zohar81
    Jun 4, 2020 at 5:54
  • And one more thing, If I'm using ssh so I'm already logged-in to valid user account. So there shouldn't be a problem to run the script from terminal command line.
    – Zohar81
    Jun 4, 2020 at 13:20
  • I did a quick search and found this similar question on StackOverflow where a commentator states the sane thing that you can’t do anything with the GUI until a user has logged in. That means you can manipulate the fields in the login box if you’re not logged in.
    – Allan
    Jun 4, 2020 at 16:15
  • An SSH login is a SHELL login and it’s very different from a GUI login. You can use SSH to create a secure tunnel and then launch VNC, but being logged in via SSH won’t allow you to manipulate a GUI unless you’re already logged into said GUI
    – Allan
    Jun 4, 2020 at 16:20

0

You must log in to answer this question.