Sunday, 25 June 2017

how to block a user

Way 1 : Move the user into /sbin/nologin shell

      syntax :  usermod username -s /sbin/nologin

                  [root@localhost ~] # usermod test -s /sbin/nologin
                

                  [root@localhost ~] # su test
            
                  This account is currently not available.

Way 2 : lock the user using passwd and usermod commands

     syntax :  passwd --lock username or usermod --lock username

                  [root@localhost ~]# passwd --lock test             
                  Locking password for user test.
                  passwd: Success

                  [root@localhost ~]# su gugu

                  [gugu@localhost ~]$ su test # login to blocked user from normal user
                  Password:
                  su: Authentication failure      

    or        [root@localhost ~]# usermod --lock test

                 [root@localhost ~]# su gugu

                 [gugu@localhost ~]$ su test # login to blocked user from normal user
                 Password:
                 su: Authentication failure

Saturday, 24 June 2017

how to enable ssh root login



   Edit the configuration file of vi /etc/ssh/sshd_config

  Change the config file from PermitRootLogin no to PermitRootLogin yes
    
     [root@localhost] # vi /etc/ssh/sshd_config
     
        # Authentication:

        #LoginGraceTime 2m
          PermitRootLogin yes
         #StrictModes yes
         #MaxAuthTries 6
         #MaxSessions 10

         #PubkeyAuthentication yes

  Then restart the service 
  
        [root@localhost] # service sshd restart
 

how to block a user

Way 1 : Move the user into /sbin/nologin shell       syntax :  usermod username -s /sbin/nologin                   [root@localhost ~] ...