Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,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 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[28,191 views]  

Remote GUI login via Apple Remote Desktop | 27 comments | Create New Account
Click here to return to the 'Remote GUI login via Apple Remote Desktop' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Remote GUI login via Apple Remote Desktop
Authored by: bdog on Wed, Jul 13 2005 at 10:25AM PDT
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 Wed, Jul 13 2005 at 10:31AM PDT
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 Wed, Jul 13 2005 at 7:05PM PDT
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 Mon, Jul 25 2005 at 11:06AM PDT
Sooo...

What modifications in specific may that be?

[ Reply to This | # ]
Remote GUI login via Apple Remote Desktop
Authored by: danbarie on Wed, Jul 13 2005 at 11:01AM PDT
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 Wed, Jul 13 2005 at 11:11AM PDT
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 Thu, Jul 14 2005 at 5:26PM PDT
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 Thu, Jul 28 2005 at 3:05PM PDT
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 Wed, Jul 13 2005 at 12:28PM PDT
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 Wed, Jul 13 2005 at 1:24PM PDT
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 Wed, Jul 13 2005 at 1:58PM PDT
ah, got it, thanks :-)

[ Reply to This | # ]
Just a reminder on how to switch to login window
Authored by: Steff-X on Wed, Jul 13 2005 at 2:00PM PDT

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 Thu, Jul 28 2005 at 3:10PM PDT
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 Fri, Aug 5 2005 at 1:52AM PDT
[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 Fri, Oct 14 2005 at 9:59AM PDT
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 Fri, Oct 14 2005 at 11:57AM PDT
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 Wed, Aug 17 2005 at 1:53PM PDT
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 Wed, Nov 9 2005 at 3:46AM PST
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 Wed, Mar 15 2006 at 9:29AM PST
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 Fri, Mar 17 2006 at 3:57PM PST
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 Tue, Feb 6 2007 at 3:27PM PST
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 Mon, Oct 10 2005 at 10:06AM PDT
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 Tue, Oct 11 2005 at 1:58PM PDT
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 Tue, Oct 11 2005 at 10:59AM PDT
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 Thu, Aug 16 2007 at 1:49PM PDT
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 Fri, Aug 17 2007 at 6:20AM PDT
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 Wed, Apr 30 2008 at 1:03PM PDT
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 | # ]