Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Security»How to disable root SSH Login and Create sudo User

    How to disable root SSH Login and Create sudo User

    RahulBy RahulJanuary 26, 20152 Mins Read

    This article is defined in two parts. First part of this article will help you to disable root ssh login from remote systems. It means system will denied all ssh requests to root user from any remote machine. In second part of this article we are creating a system user, or you can select existing user and add them to sudo access with full privileges without entering password.

    1. Disable root SSH Login in Linux

    1. Edit SSH configuration file using vim or nano or any of your favorite text editor.

    # vim /etc/ssh/sshd_config
    

    2. Now uncomment parameter PermitRootLogin and set it to ‘no‘.

    Form:
     #PermitRootLogin yes
    
    To:
     PermitRootLogin no
    

    disable root SSH Login

    3. After making above changes restart ssh service.

    # systemctl restart sshd
    [or]
    # service sshd restart
    

    2. Create User with Full Sudo Privilege

    1. Create a system user and assign password to that user. For example I am creating a user named ‘rahul’.

    # useradd rahul
    # passwd rahul
    

    2. Now Add user in sudo access without password. Edit sudo configuration file using following command

    # visudo
    

    and add following values at end of file. Change rahul with your actual user name.

    rahul ALL = NOPASSWD: ALL
    

    full_sudo_access

    3. Now login as user rahul to your system and type following command, You will get root access without entering any password.

    [[email protected] ~]$ sudo su -
    Last login: Fri Mar 20 22:28:12 IST 2015 on pts/1
    [[email protected] ~]#
    

    You can also run all command from user rahul with root privileges by adding sudo in start of command. for example

    [[email protected] ~]$ sudo service network restart
    
    Restarting network (via systemctl):                        [  OK  ]
    
    disable login root SSH
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleWhat is Apache Prefork, Worker and Event MPM (Multi-Processing Modules)
    Next Article How do I Install and Use Iptables on CentOS/RHEL 7

    Related Posts

    (Resolved) userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms

    Updated:May 10, 20221 Min Read

    Adding a New SSH Key in GitHub

    Updated:April 1, 20223 Mins Read

    How to Install and Configure Fail2ban on Debian 11

    3 Mins Read

    How to Create SFTP Only User in Debian 11

    Updated:September 26, 20214 Mins Read

    How to Disable Strict Host Key Checking in SSH

    Updated:September 25, 20212 Mins Read

    How To Set Up SSH Keys in Linux

    5 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install Sublime Text 4 on Ubuntu 22.04
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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