Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Remote GUI login via Apple Remote Desktop Network
Using Apple Remote Desktop, send the following UNIX Command to as many machines as you like to log them in. I suggest sending the command as the user you are logging in as. Note that this will only work if the machine is currently at the login screen.
osascript -e 'tell application "System Events" to keystroke "LOGIN_NAME"'; \
osascript -e 'tell application "System Events" to keystroke tab'; \
osascript -e 'tell application "System Events" to delay 0.5'; \
osascript -e 'tell application "System Events" to keystroke "PASSWORDHERE"'; \
osascript -e 'tell application "System Events" to delay 0.5'; \
osascript -e 'tell application "System Events" to keystroke return'
Replace LOGIN_NAME and PASSWORD with the proper values, of course...

[robg adds: I broke the above command by adding backslashes to split the lines; it should work when copied and pasted, but ... I haven't tested this one, lacking both Apple Remote Desktop and more than one machine here in the temporary Boston HQ of macosxhints...]
    •    
  • Currently 3.75 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[54,281 views]  

Remote GUI login via Apple Remote Desktop | 28 comments | Create New Account
Click here to return to the 'Remote GUI login via Apple Remote Desktop' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Remote GUI login via Apple Remote Desktop
Authored by: bdog on Jul 13, '05 10:25:54AM

Oh wow! Thank you! This will save a lot of time in the labs.



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: diamondsw on Jul 13, '05 10:31:38AM

Won't this require modification if you're displaying a list of users?

Also, another way of accomplishing this is to use the built-in VNC server, but I know that's not always an option.



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: telegramsam on Jul 13, '05 07:05:27PM

Yes, this would require some slight modification when using a displayed list of users, but you could achieve the same effect.

---
What is signature?



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: Der Kommissar on Jul 25, '05 11:06:10AM

Sooo...

What modifications in specific may that be?



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: danbarie on Jul 13, '05 11:01:56AM

Anyone know of a way to do this without Apple Remote Desktop, say using ssh?



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: TylerL on Jul 13, '05 11:11:21AM
This can also be accomplished with only one line (split up for table happiness):
osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' -e 'keystroke tab' \
-e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
And yes, this should work fine through SSH too. Just make sure the screen's at the loginwindow :p

[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: telegramsam on Jul 14, '05 05:26:35PM

Acutally, it won't work through SSH... it gives some error about not being able to communicate with the window manager or something.

---
What is signature?



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: nukethis on Jul 28, '05 03:05:27PM

You need to sudo the command first. Then it will work.



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: headphonejack on Jul 13, '05 12:28:17PM

Sorry I am "on the line" for that hint?
What is it for, when I am already at the loginscreen, there I can use ARD to just enter log and pass?

Does this hint wake up the machines on WAN?

thanks



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: giskard22 on Jul 13, '05 01:24:17PM

Some of us would like to be able to log in, say, 20 computers at the same time. That's the point of this hint. Also, there are some tasks I would like to automate that require the GUI; this will also make that possible. So that's the point. :)



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: headphonejack on Jul 13, '05 01:58:13PM

ah, got it, thanks :-)



[ Reply to This | # ]
Just a reminder on how to switch to login window
Authored by: Steff-X on Jul 13, '05 02:00:45PM

Very interesting hint. Thanks.

Let me remind to you that a command to switch to the login window has already been given here :

/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend

If you want to know more about this, search MacOSXhints for "user.menu"

[ Reply to This | # ]

Remote GUI login via Apple Remote Desktop
Authored by: nukethis on Jul 28, '05 03:10:18PM

So, I know this hint works via ssh via sudo. Knowing this, can someone write a applescript or some sort of unix script that ssh's into one machine, do the command, then goes to the next machine? Say 20 machines start at 192.168.80.2 and end at 192.168.80.21 . So basically bypassing Apple Remote Desktop.



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: tomtux on Aug 05, '05 01:52:35AM

[code]
#!/bin/sh
ssh root@192.168.80.2 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.3 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.4 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.5 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.6 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.7 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.8 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.9 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.10 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.11 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.12 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.13 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.14 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.15 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.16 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.17 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.18 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.19 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.20 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
ssh root@192.168.80.21 osascript -e 'tell application "System Events"' -e 'keystroke "LOGIN_NAME"' \
-e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORDHERE"' -e 'delay 0.5' -e 'keystroke return' -e 'end tell'
[/code]
It is probably helpful if the root user on all of the lab machines have their private key copied to the place where this script is going to be used in the .ssh/authorized_keys. Although its a security risk you may not wish to use a passphrase so you don't have to keep inputting the root user of each machine.



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: cpbaldwin on Oct 14, '05 09:59:09AM

ah, figured it out! First, I have to include the path to the comand I want run. Second, there is problem sometimes with calling muliple commands, so I had to put the command in a string to get it to work.

#!/bin/bash

COMPUTERS=0
IPADDR="192.168.80."
STARTIP=2
COM1="/usr/bin/osascript -e 'tell application "System Events" to keystroke "USERNAME"';/usr/bin/osascript -e 'tell application "System Events" to keystroke tab';/usr/bin/osascript -e 'tell application "System Events" to delay 0.5';/usr/bin/osascript -e 'tell application "System Events" to keystroke "PASSWORD"';/usr/bin/osascript -e 'tell application "System Events" to keystroke return'"
i=0
clear

while [ $i -le "$COMPUTERS" ]
do

echo "Logging into..."$IPADDR$startip

ssh root@$IPADDR$STARTIP $COM1

i=$(($i+1)) #this is for the loop counter
startip=$(($startip+1)) #this sets the ip address

done

exit 0



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: cpbaldwin on Oct 14, '05 11:57:15AM

Oh, I forgot to change something for nukethis. the Variable COMPUTERS needs to be changed from 0 to 20 for the number of computers you have.



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: topkat2000 on Aug 17, '05 01:53:00PM

This is an awesome tip, and I would really love to use it in our lab...but there is one problem. The last line of the script isn't working...the "keystroke return" isn't being processed by the machines correctly.

Instead of a return being entered, and the login proceeding, the password field simply becomes highlighted. If I then physically press return on the machines' keyboards, the login proceeds. Anyone have any idea why the keystroke return would not be processed correctly and truly result in a return? I'm using 10.4.2... might it be some sort of security setting? Thanks in advance!



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: kraaft on Nov 09, '05 03:46:15AM
This happens when your users are displayed as list. Here's a modified script. To choose the desired user enter just as many characters as are need to identify it.

osascript -e 'tell application "System Events"' -e 'keystroke "CHARACTERS"' \
-e 'keystroke return' \
-e 'delay 1' -e 'keystroke "PASSWORD"' -e 'delay 0.5' -e 'keystroke return' \
-e 'end tell'
You can also experiment with the delay times

[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: YB on Mar 15, '06 09:29:10AM

Was anyone able to find a solution for the "keystroke return" problem?
It seems the username and password gets entered on the 10.4 server GUI login but "return" does not take place.

Any idea.



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: genericuser on Mar 17, '06 03:57:52PM

Blah. Can't remember my username or password for this site, but it won't send a new e-mail to my account, because it's apparently already in the system. Sheesh.

Anyway, I figured out the fix.

osascript -e 'tell application "System Events"' -e 'keystroke "USERNAME"' -e 'keystroke tab' -e 'delay 0.5' -e 'keystroke "PASSWORD"' -e 'delay 0.5' -e 'keystroke tab' -e 'keystroke return' -e 'end tell'

Not sure why, but you need to pass a tab instance between entering the password and sending the final return key command. Don't ask me why I even thought to try this; I have no idea. But it fixed the problem, which I was also having. :)

HTH --



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: osso on Feb 06, '07 03:27:03PM

I had this trouble too and have spent hours and hours on this. I finally got the command to work with 5 returns at the end. I actually had to run the command twice. I am not a programmer but I couldn't find anyone that had cleaner code and who cares it runs.



osascript <<EndOfMyScript
tell application "System Events"
keystroke "USERNAME"
keystroke tab
delay 0.5
keystroke "PASSWORD"
delay 0.5
keystroke return
keystroke tab
delay 0.5
keystroke "PASSWORD"
delay 0.5
keystroke return
keystroke return
keystroke return
keystroke return
keystroke return
end tell
EndOfMyScript


I hope that helps because I signed up with Mac OS X hints just to let you know what I found.



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: brettev on Oct 10, '05 10:06:31AM

I am trying to get my server working like MS remote desktop where each user can log in with a separate desktop and run them all simultaneously in the background of the console. I was thinking of a way that you could ssh in and create a separate desktop running a different instance of vnc and then connecting to that vnc session on the separate desktop. ANy hints on getting that separate gui session running using ssh?



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: cpbaldwin on Oct 11, '05 01:58:44PM

Try X11, I don't know if it's what your looking for or not.

http://www.apple.com/downloads/macosx/apple/x11formacosx.html



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: cpbaldwin on Oct 11, '05 10:59:22AM

Based on the example you gave and if all computers use the same username and password a bash shell script would look like this. Also is an Applescript example below. The problem, is that neither one of them work. Just using the single line you gave don't work for me. If I ssh into the computer first and then give each command one by one it works, which defeats the purpose of this script.
Same with the Applescript. It just don't work. Everything that I've found and read about this indicates that both of these should work. If anybody out there can help figure this one out, I would appreciate it a lot.

#!/bin/bash

COMPUTERS=20
IPADDR="192.0.80."
USERNAME="username"
PASSWORD="password"
i=0
startip=2

while [ $i -le "$COMPUTERS" ]
do

ssh root@$IPADDR$startip osascript -e 'tell application "System Events" to keystroke "$USERNAME"';osascript -e 'tell application "System Events" to keystroke tab';osascript -e 'tell application "System Events" to delay 0.5';osascript -e 'tell application "System Events" to keystroke "$PASSWORD"';osascript -e 'tell application "System Events" to delay 0.5';osascript -e 'tell application "System Events" to keystroke return'

i=$(($i+1)) #this is for the loop counter
startip=$(($startip+1)) #this sets the ip address

done

exit 0

This is an Applescript script...

property COMPUTERS : 20
property IPADDR : "192.168.80."
property USERNAME : "username"
property passwd : "password"

set counter to 2

repeat COMPUTERS times
set tempip to "eppc://" & USERNAME & ":" & passwd & "@" & IPADDR & counter
set remote_computer to application "System Events" of machine tempip
using terms from application "System Events"
tell remote_computer
keystroke USERNAME
keystroke tab
delay 0.5
keystroke passwd
delay 0.5
keystroke return
end tell
end using terms from
set counter to counter + 1
end repeat



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: Virtual1 on Aug 16, '07 01:49:41PM

I have been successfully using this hint until the intels came out. I have found that on all intel machines, the "keypress return" merely causes the entire password field to highlight, rather than to proceed to login. I have tested this on over 100 machines here and it exclusively works on the 10.3 and 10.4 ppc machines. (does not work at all on 10.2 or earlier)

I have tinkered around with pressing return more than once, pressing return with the focus in other fields, various delays, etc, but have not found anything that works. Is there an alternate applescript command that will trigger the login button? Or is there a keypress for the enter key maybe? I can't find any scripting information on the loginwindow process to find a specific command to send it to login.


---
I work for the Department of Redundancy Department



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: UCCA_TomGriffin on Aug 17, '07 06:20:36AM
Hi, I had the same problem but it led me to this link! Problem solved for me.

http://lists.apple.com/archives/Remote-desktop/2007/Apr/msg00037.html

Regards Tom

[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: loren_ryter on Apr 30, '08 01:03:56PM

does anyone know if this is possible on leopard? It seems that "system events" is not a process that is running after restart at the login screen.



[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: cashxx on Mar 07, '14 07:55:25AM

Was also having this problem and forgot about it because I haven't used it and some people on Macenterprise forums posted the fixes, the top two lines are added for the problematic OS's like Mt Lion, etc.

osascript -e 'tell application "SecurityAgent" to activate'; \
osascript -e 'tell application "Bluetooth Setup Assistant" to quit'; \
osascript -e 'tell application "System Events" to keystroke "yourUsername"'; \
osascript -e 'tell application "System Events" to keystroke tab'; \
osascript -e 'tell application "System Events" to delay 0.5'; \
osascript -e 'tell application "System Events" to keystroke "yourPassword"'; \
osascript -e 'tell application "System Events" to delay 0.5'; \
osascript -e 'tell application "System Events" to keystroke return'



[ Reply to This | # ]