×



Do you need to install a sudo package on OpenSUSE Linux?
This guide is for you.

Managing a Linux system with sudo is safer and more accessible. Sudo log all commands and other information to /var/log/ directory.  
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform OpenSUSE Linux related tasks.
In this context, we shall look into the steps to install sudo on OpenSUSE Linux when not installed by default.

How to install sudo command on OpenSUSE Linux ?

To do this, follow the process given below;

i. Open the Terminal Window. For remote server login using the ssh command.
ii. Search sudo package using zypper search sudo.
iii. Install sudo in OpenSUSE Linux, run: zypper in sudo.
iv. Configure sudo and test it.
v. Disable direct root access via ssh and use the sudo for admin tasks.

Now, we will look into all commands and examples in more details.

1. How to Search for package using zypper ?

To use zypper command, simply execute;
# zypper search sudo
To get information about the sudo package, run the command below;
# zypper info sudo

2. How to use OpenSUSE install sudo using zypper ?

Here you can search and lookup for sudo package using the command below;
# zypper in sudo

3. How to Configure sudo on OpenSUSE ?

Here, you can enable sudo access for a user account by running the command:
# visudo
Here, ensure that the following line exists:
#includedir /etc/sudoers.d
Next find and comment out the following two lines so that only users in wheel group can run sudo command:
#Defaults targetpw # ask for the password of the target user i.e. root
#ALL ALL=(ALL) ALL # WARNING! Only use this together with 'Defaults targetpw'!
After this, save and close the file.

How to Configure sudo group1 group ?

To create a new config file, execute the command:
# visudo -f /etc/sudoers.d/group1-users
Then add the following config information:
# Allow members of group group1 to execute any command
%wheel ALL=(ALL) ALL
After this, Save and close the file by pressing ESC followed by :x.

How to set and user group access ?

Start by adding a new group named group1 using the groupadd command as shown below:
# groupadd group1
To verify it, you can use the grep command and /etc/group file as shown below:
# grep ^group1 /etc/group
Then, you can add existing user named 'linuxapt' to the group1 group as follows:
# usermod -aG wheel {username}
# usermod -aG wheel linuxapt
Next, verify it with the id command:
id linuxapt

How to run applications or commands with root permissions?

All members of the gruop1 group can run sudo command using the following syntax:
sudo command
sudo command arg1 arg2
sudo ls -l /etc/shadow
sudo systemctl restart nginx.service 
To use root shell, simply execute:
sudo -i

How to Disable ssh based root access ?

First, install ssh keys for vivek user in your remote/locate OpenSUSE Linux server using the ssh-copy-id command:

ssh-copy-id -i ~/.ssh/id_rsa.pub linuxapt@ln.opensuse
OR
ssh-copy-id -i ~/.ssh/id_ed25519.pub linuxapt@ln.opensuse

You can verify that you can login and use sudo:
ssh linuxapt@ln.opensuse
sudo -i
Finally, on your OpenSUSE Linux edit the /etc/ssh/sshd_config, execute:
# vi /etc/ssh/sshd_config
Then update the sshd_config file as shown below:
## disable all password login including root user login ##
ChallengeResponseAuthentication no
PasswordAuthentication no
PermitRootLogin no
UsePAM no
Then restart or reload OpenSSHD service:
# systemctl restart sshd.service

[Need urgent OpenSUSE Linux support ? We are available to help you today.]


Conclusion


More Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on IbmiMedia.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com