Search code examples
linuxsecuritywhitelist

How can I define other level of security on linux that requires users to login using a registered device?


Is there any method to define another level of security that users are forced to use a single predefined device, while connecting to linux server via SSH. For instance, user1 (with his username/password) is only allowed to use pc1 to connect to linux server, so I need to define a white list concept in linux server, so if user1 attempts to login with pc2 with the correct username and password the connection will be denied. How can we uniquely address pc1 to user1? What kind of address I need to use? the mac address is not usable since machines are in a different subnet with server, and IP address is not always remaining the same.


Solution

  • For machines with fixed IPs, you add the following to your /etc/ssh/sshd_config:

    DenyUsers *
    AllowUsers user3
    Match Address pc1
        AllowUsers user1
    
    Match Address pc2
        AllowUsers user2
    

    Line 1 may be too strict, forbidding access to any user by default. The example at line 2 allows user3 to log from any machine.

    For use cases like that described by Mahsa, host-based authentication will be the way to go, with HostbasedUsesNameFromPacketOnly enabled.

    More information at the sshd_config manpage and at this tutorial.