Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Disable GUI/SSH Login for specific users

I have two groups,

  1. sshonly
  2. guionly


As the name suggestes i want only ssh login permitted to the first group of users and only gui login permitted to the next group of users.

Is it possible?

MacBook Pro, OS X Mountain Lion (10.8.3)

Posted on May 8, 2013 11:15 PM

Reply
Question marked as Best reply

Posted on May 9, 2013 12:04 AM

You can manage which users have access to Remove Login (SSH) by selecting this service in the Sharing system preferences, and then clicking the "Only these users" radio button and populating the list with the usernames (or groups) that you would like to allow SSH access.


Unfortunately there is no way to prevent a user from logging in. Apple includes "Sharing Only" account options that are meant for this purpose, but I believe SSH sessions require an account that has a home folder environment (I'm not sure about this, but I believe it is the case).


You can try creating a sharing only account and then adding it to your sshonly group, and then only enable this group in the Remote Login service to see if you can grant it SSH access this way, but if not then I believe there is only a partial answer to your request, which only allowing some users SSH access, though all users will have local login access.

9 replies
Question marked as Best reply

May 9, 2013 12:04 AM in response to vaira123

You can manage which users have access to Remove Login (SSH) by selecting this service in the Sharing system preferences, and then clicking the "Only these users" radio button and populating the list with the usernames (or groups) that you would like to allow SSH access.


Unfortunately there is no way to prevent a user from logging in. Apple includes "Sharing Only" account options that are meant for this purpose, but I believe SSH sessions require an account that has a home folder environment (I'm not sure about this, but I believe it is the case).


You can try creating a sharing only account and then adding it to your sshonly group, and then only enable this group in the Remote Login service to see if you can grant it SSH access this way, but if not then I believe there is only a partial answer to your request, which only allowing some users SSH access, though all users will have local login access.

May 9, 2013 3:20 AM in response to vaira123

Ok Solved it. This is what i did.

Create a user with "standard" previlage not "sharing only"

Because "sharing only" user has no shell or no home directory. You need both of that for ssh login.


  1. To Enable ssh

    Select the user/group in remote access option system preferences -> sharing

  2. To Disable ssh

    Dont select the user 😝

  3. To Enable GUI Login

    Default enabled, so dont have to do anything again

  4. To Disable GUI Login
    • There are two things you can do (http://hints.macworld.com/article.php?story=20080127172157404)
      1. Disable all the user with userid less than 500 to not have a gui login, this is the command for that
        $ sudo defaults write /Library/Preferences/com.apple.loginwindow Hide500Users -bool TRUE
      2. Or else add specific users to the hiddenuser list, i prefer this one, because we don't have to change the user id just for this.
        $ sudo defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array $USERNAME
    • And finally remove the other option from the login window
  • $ sudo defaults write /Library/Preferences/com.apple.loginwindow SHOWOTHERUSERS_MANAGED -bool FALSE

May 9, 2013 6:13 AM in response to BobHarris

Good point, though isnt this a bit redundant with the system's ssh user management in the Sharing system preferences? I guess the difference is Apple's approach is to restrict access by having a group called "access_ssh" in the OS X directory services to which SSH-enabled accounts can be added, wherease the classic approach you mentioned is to adjust the ssh daemon configuration itself.

Disable GUI/SSH Login for specific users

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.