Autologin

ernstcs
Contributor III

Hey All,

I am sure this is a simple thing, but let's say I have autologin configured
for a user account. The autologin works at a reboot like it should.

Let's say the account does a standard logout so now it returns to a login
screen.

Is there a way to invoke the system to autologin again without having to
reboot from the command line or by starting/stopping process(es)?

Thanks,

Craig E

8 REPLIES 8

jarednichols
Honored Contributor

I'm not sure you'd want to do that. What if you need to log in with an admin account or something? The second you logged out after login, it would log you back in again. Am I missing something?
---
Jared F. Nichols
Desktop Engineer, Infrastructure & Operations
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436

ernstcs
Contributor III

Yes you are. =) HOW DARE YOU QUESTION ME!

Just kidding...

No you are right about that potential problem. Once this account does what it needs to do I fully intend to delete the user account, disable auto logon, and restore my loginwindow preferences to what they should be. =)

Want to trigger a policy by a specific username login. I do it now with a reboot after I apply my autologin packs and I am trying to get away from the reboot because it’s causing some issues on occasion.

Pretty sure the new jamfHelper is doing this for CS installs at FirstRun. Adds the user account and somehow is making it login...

Craig E

talkingmoose
Moderator
Moderator

How about a five-minute interval launchd .plist that checks for whether or
not a user is logged in? You can probably grep 'last console' for 'still
logged in'.

If the script returns 'false' because it can't find 'still logged in' then
you can reboot the system and let your autologin work as designed.

--

bill

William M. Smith, Technical Analyst
MCS IT
Merrill Communications, LLC
(651) 632-1492

ktrampe
New Contributor II

I'm also curious as to why you'd want this, however, I have done some pretty strange things in the past... ;)

Anyhow, here's how I think I'd do it:

  1. Set up a logout policy for that machine on the JSS, I'd make it ongoing and if you'd like, check the "Make Available Offline" checkbox.
  2. Write a shell script somewhere along these lines:

osascript -e 'tell application "System Events" to delay 10';
osascript -e 'tell application "System Events" to keystroke "usernamehere"';
osascript -e 'tell application "System Events" to delay 3';
osascript -e 'tell application "System Events" to keystroke return';
osascript -e 'tell application "System Events" to delay 3';
osascript -e 'tell application "System Events" to keystroke "userpasswordhere"';
osascript -e 'tell application "System Events" to delay 3';
osascript -e 'tell application "System Events" to keystroke return';

Depending on how your login window is configured, and how long you'd like it to wait before logging in as the user.

Hope this helps!

Cheers,

Kerry
BASD Net Admin

ernstcs
Contributor III

Thanks Kerry.

Would the first return be a tab rather to move down a field?

Craig E

ktrampe
New Contributor II

No problem, I'm pretty sure either would work. I use this with ARD's "send unix" command when I want to log a bunch of computers in at once for any reason. It's GREAT for load testing, etc.

Luck! ;)

Kerry

Not applicable

The tech before me at a site used this with ARD and Send Unix command to login as a local user. it seems to work better for me, and we use the name and password login window.

sudo osascript -e 'tell application "system events" to tell process "SecurityAgent" to keystroke "student password "'

I think the "student" is the shortname and "pwassword " is the password, " " and " " must be Tab and Return. less to type I guess.

Nathaniel Lindley

++++++++++
Information Technology
Saint Paul Public Schools
Saint Paul, Minnesota
nathaniel.lindley at spps.org
phone: 651-248-6861

ktrampe
New Contributor II

Thanks Nathaniel, that is a great script and works wonderfully on newer machines.
I would be remiss if I failed to mention that I attempted to use a script very similar to this one a couple years ago but was running into problems with it skipping letters in the password field, putting the user and pass all in the "user" field, or sometimes it would not work at all on our older G3 machines with 10.3.9. That's why I resorted to adding the "delays"; it seems it allowed the machine enough time to catch up with the script... apparently. Maybe it was just ARD?

Anyhow, if you've got nothing older than a G4, you'll probably be fine with the one-liner, otherwise, if you're using ARD, you could use the "template" feature to prevent having to type it or paste it again and again.

Hoping to prevent headaches, ;)
Kerry