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: #PermitRootLoginyes To: PermitRootLoginno
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
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 ]