Skip to navigation Skip to content
Chennai Web Hosting – Official Blog

Chennai Web Hosting – Official Blog

  • HOW TO’S
  • DATABASE
  • LINUX
    • CentOS / REDHAT
      • CentOS 7 / RHEL 7
      • CentOS 6 / RHEL 6
    • DEBIAN
    • FEDORA
    • UBUNTU
  • CONTROL PANEL
    • cPanel
    • CentOS WEB PANEL
    • PLESK
    • DIRECT ADMIN
    • OTHERS
  • WEB SERVERS
    • APACHE
    • LIGHTSPEED
    • NGINX
  • MONITORING TOOLS
    • CACTI
    • ICINGA
    • NAGIOS
    • ZABBIX
    • OTHERS
  • BASIC COMMANDS
  • MISCELLANEOUS
Chennai Web Hosting – Official Blog
Chennai Web Hosting – Official Blog

Chennai Web Hosting – Official Blog

  • HOW TO’S
  • DATABASE
  • LINUX
    • CentOS / REDHAT
      • CentOS 7 / RHEL 7
      • CentOS 6 / RHEL 6
    • DEBIAN
    • FEDORA
    • UBUNTU
  • CONTROL PANEL
    • cPanel
    • CentOS WEB PANEL
    • PLESK
    • DIRECT ADMIN
    • OTHERS
  • WEB SERVERS
    • APACHE
    • LIGHTSPEED
    • NGINX
  • MONITORING TOOLS
    • CACTI
    • ICINGA
    • NAGIOS
    • ZABBIX
    • OTHERS
  • BASIC COMMANDS
  • MISCELLANEOUS
Recent Blogs
  • 13 Basic Cat Commands in Linux September 28, 2021
  • Top 20 Exim Mail Queue Commands September 24, 2021
  • 15 useful rsync Commands in Linux September 23, 2021
  • Find Command in Linux September 23, 2021
  • Top 50 Linux Commands September 22, 2021
  • Important Linux Commands with Examples September 22, 2021
  • How to check memory usage on CentOS Server September 9, 2021
  • How to enable and customize PHP-FPM directives for a domain/server wide September 9, 2021
  • cPanel Logs – Apache, Access, Email, Error, FTP, MySQL, WHM September 9, 2021
  • Web Server migration without down time (WHM) September 6, 2021
  • Home
  • HOME
  • Permitting SSH login through su user in CentOs
CentOS 6 / RHEL 6CentOS 7 / RHEL 7HOMELINUX

Permitting SSH login through su user in CentOs

November 21, 20190
SSH Root

Disabling direct root login and Permitting through “su” user in Linux

Does everyone knows, nowadays we have facing number of Hacking attempts. Especially in linux servers,  we need to enable/disable some components to prevent those kind of hacking attempts. By default the root user is enabled in linux server and it is not recommended. For a security measure we have to disable the direct root access and permit via su user.

From this post, we are going to see how to secure our server’s SSH login with additional security.

1.Prerequisites

  • CentOS 7.3 (Operating system used here)
  • root privileges.

Let’s continue with creating the user

2.Creating new user

To create the su user and disable ssh root login from outside world, follow the below steps.

#adduser webhost
[root@webhostingchennai ~]# adduser webhost
[root@webhostingchennai ~]# passwd webhost
Changing password for user webhost.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

If you want to give a super user access to existing user, just add the user to group file.

3.Adding the user to wheel group

Now, we need to add the user to “wheel” group to make the user as a “su” user. edit /etc/group file to add it.

# nano /etc/group

Normal, output of group file will be as follows

GNU nano 2.3.1 File: /etc/group

root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mem:x:8:
kmem:x:9:
wheel:x:10:
cdrom:x:11:
mail:x:12:postfix
man:x:15:
dialout:x:18:
floppy:x:19:
games:x:20:
tape:x:30:
. . . 
. . .

After adding the user to the “wheel” group, save the file and confirm that the user was added to “wheel” group using the following command.

# cat /etc/group | grep wheel

You can confirm it by the following output

[root@webhostingchennai ~]# cat /etc/group | grep wheel
wheel:x:10:webhost
[root@webhostingchennai ~]#

4.Disabling direct Root access

By editing the /etc/ssh/sshd_config file and uncomment the “PermitRootLogin” to “no” to disable the direct ssh root login.

# nano /etc/ssh/sshd_config

Output of sshd_config file be like:

# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $

# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

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

#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

. . .

. . .

Once the modification was done as above,  restart the ssh service using

You can also modify the ssh port number for additional security, click here

# systemctl restart sshd.service

5.Login Directly via root user

Now, let try to login the server via root user to check whether it’s login directly root or not.

Using username "root".
root@103.12.211.150's password:
Access denied
root@103.12.211.150's password:

Yes, It is not allowing to login directly as root, so we are in right path.

6.Login via “su” user

Now, try to login the server with su user and successfully login to server.

Using username "webhost".
webhost@103.12.211.150's password:
[webhost@webhostingchennai ~]$ su -
Password:

Last login: Tue Dec 26 12:07:39 EET 2017 from 182.13.23.38
[root@webhostingchennai ~]#

Yes, now we can able to login to the server using su user.

Related tags : Disabling direct root login enabling su user in linux login using su user in linux

Post navigation

Previous Article

5 Simple steps to change SSH port in Centos

Next Article

Installing Lighttpd with PHP-FPM and Mysql on CentOS 7

Comment here Cancel reply

Categories

  • BASIC COMMANDS (2)
  • CACTI (1)
  • CentOS / REDHAT (1)
  • CentOS / REDHAT (9)
  • CentOS 6 / RHEL 6 (10)
  • CentOS 7 / RHEL 7 (11)
  • cPanel (2)
  • DATABASE (2)
  • DEBIAN (2)
  • Exim (1)
  • FEDORA (1)
  • HOME (3)
  • HOW TO'S (1)
  • LINUX (13)
  • MONITORING TOOLS (1)
  • MySQL (2)
  • UBUNTU (4)
  • VPS (4)
  • WHM (2)

Archive

  • September 2021 (12)
  • August 2021 (3)
  • July 2021 (1)
  • June 2021 (3)
  • November 2019 (5)
WordPress Theme : VMagazine News
  • Domain Registration
  • Web Hosting
  • Reseller Hosting
  • VPS Hosting