Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7617025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:02:28+00:00 2026-05-31T03:02:28+00:00

Is it possible to have a PAM module that checks to see if a

  • 0

Is it possible to have a PAM module that checks to see if a user attempting login via OpenSSH is already logged in and if they are then deny the 2nd login?

I’ve tried several other way to prevent more than one login session but nothing is working, if someone can confirm this is doable using a custom PAM module I’d be very grateful, thanks.

I noticed the limits.conf works ok when I comment out the sftp config:

# SFTP + Port Forwarding Only for Normal Users
# Create home directory in /home/%u and set permissions to user / sftponly
# then do a usermod -d / user
# In Tunnelier set user home to /home

#Subsystem sftp /usr/lib/openssh/sftp-server

#Match group sftponly
#ChrootDirectory /home/%u
#X11Forwarding no
#AllowTcpForwarding yes
#ForceCommand internal-sftp

but it breaks the sftp.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:02:30+00:00Added an answer on May 31, 2026 at 3:02 am

    You could check the number of active login sessions using utmp or utmpx, a simple loop something like this:

    #include <utmpx.h>
    
    int get_num_login_sessions( const char* username )
    {
        int num_active_sessions = 0;
        struct utmpx* ent = NULL;
        setutxent();
        while( (ent = getutxent()) != NULL )
        {
            if( ent->ut_type == USER_PROCESS &&
                strcmp(username, ent->ut_user) == 0 )
            {
                num_active_sessions++;
            }
        }
        endutxent();
        return num_active_sessions;
    }
    

    See the wikipedia entry for utmp: http://en.wikipedia.org/wiki/Utmp

    If you created a pam module that did this and stacked it at the top of your auth stack you could fail if the number of active sessions was more than 0 (so long as your module was stacked as requisite or required).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to have a relationship from a user table to a system
Is it possible to have multiple classes that inherit/extends same class in Google AppEngine
In SQL its possible to have fields that cannot contain duplicate data. How is
it's possible to have one entity object (class, e.g. User) for more entity models
Is it possible to have a div or table column expandable by the user
I have heard that it is possible to have a local Git repository on
It is theoretically possible to have a converter, that scans the color areas of
Is it possible have two projects with the same name in flex builder? Here
is possible to have a separator between elements of a GridView? Thanks
Is it possible to have an association mapping a table to itself? e.g. Table:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.