Facebook Twitter Instagram
    WiredRevolution.com
    • Home
    • About
    • Contact Us
    • Essential Linux Commands
    • Sitemap
    Facebook Twitter Instagram
    WiredRevolution.com
    system administration

    Setup user login restrictions with SSH

    RyanBy RyanFebruary 4, 20091 Comment2 Mins Read
    Facebook Twitter Pinterest LinkedIn Reddit WhatsApp Email

    At various times it is necessary to restrict the users which can access a certain host. If your network relies on SSH it is as simple as changing an option in the sshd_config configuration file. You will of course need root access to make the necessary changes to this file and eventually reset the SSH daemon.

    This configuration file is usually located here.
    /etc/ssh/sshd_config

    Open the file as root in order to make changes.

    $ sudo vim /etc/ssh/sshd_config
    

    You need to set the AllowUsers keyword followed by the users you want to have access to the machine.

    AllowUsers	ryan joe
    

    If you want to do something more complex here is the output from the man page:

    AllowUsers
    This keyword can be followed by a list of user name patterns, separated by spaces. If specified, login is allowed only for user names that match one of the patterns. ‘*’ and ‘?’ can be used as wildcards in the patterns. Only user names are valid; a numerical user ID is not recognized. By default, login is allowed for all users. If the pattern takes the form USER@HOST then USER and HOST are separately checked, restricting logins to particular users from particular hosts.

    Another helpful to set the PermitRootLogin to ‘no’ so that the root account is inaccessible.

    PermitRootLogin  no
    

    When these settings have been changed go ahead and restart the SSH daemon.

    $ sudo /etc/init.d/sshd restart
    

    There are of course ways around this if other users have access to sudo or the root account. But for the most part it is a good way to restrict user access.

    Share. Facebook Twitter Pinterest LinkedIn WhatsApp Reddit Email
    Previous ArticleEnable HDMI output on Dell XPS M1530/M1330 with Ubuntu
    Next Article New Look

    Related Posts

    Transfer your ssh public key to a remote machine

    Fix git-upload-pack and git-receive-pack errors on shared hosting

    Setup SSH access between VirtualBox Host and Guest VMs

    Most Commented
    March 12, 2009

    Fix blue tinted video in Ubuntu

    September 10, 2010

    Setup SSH access between VirtualBox Host and Guest VMs

    March 8, 2011

    Install GNOME Shell in Ubuntu 10.10 Maverick

    April 4, 2009

    Setup the PS3 Bluetooth Controller on Ubuntu

    October 22, 2008

    How to correctly use LD_LIBRARY_PATH

    Recent Comments
    • Execute command on linux virtual machine (or server) from windows commandline on Setup SSH access between VirtualBox Host and Guest VMs
    • Solved: How to SSH to a VirtualBox guest externally through a host? - Daily Developer Blog on Setup SSH access between VirtualBox Host and Guest VMs
    • How to SSH to a VirtualBox guest externally through a host? [closed] – Code D3 on Setup SSH access between VirtualBox Host and Guest VMs
    • How to copy and paste from VirtualBox? [duplicate] on Setup SSH access between VirtualBox Host and Guest VMs
    • Jackie Laguna on Fix OpenGL: ChoosePixelFormat SketchUp error in WINE
    © 2026 ThemeSphere. Designed by ThemeSphere.

    Type above and press Enter to search. Press Esc to cancel.