| Advertise on warmetal.nl! Click for more information about advertising here. |
Did you find this website useful? Did I save you a lot of time? |
|
sudo sudo -u <adminuser> bash
This will give you a bash shell owned by the adminuser you specified. This can be blocked however, you could set that users can only sudo as root by adjusting the ALL within the () signs.
susesudo:~ # cat /etc/sudoers # sudoers file. # # This file MUST be edited with the 'visudo' command as root. # # See the sudoers man page for the details on how to write a sudoers file. # # Host alias specification # User alias specification # Cmnd alias specification # Defaults specification # prevent environment variables from influencing programs in an # unexpected or harmful way (CVE-2005-2959, CVE-2005-4158, # CVE-2006-0151) Defaults always_set_home Defaults env_reset # In the default (unconfigured) configuration, sudo asks for the root password. # This allows use of an ordinary user account for administration of a freshly # installed system. When configuring sudo, delete the two # following lines: 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'! # Runas alias specification # User privilege specification root ALL=(ALL) ALL # Uncomment to allow people in group wheel to run all commands # %wheel ALL=(ALL) ALL # Same thing without a password # %wheel ALL=(ALL) NOPASSWD: ALL # Samples # %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom # %users localhost=/sbin/shutdown -h now
susesudo:~ # id sjoerd uid=610(sjoerd) gid=606(ssh-access) groups=606(ssh-access),612(ssh-ict)
So when you want to add a group like that you can enter this line in the sudo file:
%ssh-ict ALL=(ALL) NOPASSWD: ALL
which will give everyone in this group passwordless sudo access.
If you consider all security and limitation consideration I would use this sudo file:
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
# Host alias specification
# User alias specification
# Cmnd alias specification
Cmnd_Alias SHELLS = /bin/sh, /bin/bsh, /bin/csh, /bin/ksh, /bin/tsh, /bin/ksh93, \
/usr/bin/sh, /usr/bin/bsh, /usr/bin/csh, /usr/bin/ksh, \
/usr/bin/tsh, /usr/bin/ksh93, /usr/bin/rksh, /usr/bin/rksh93, \
/usr/sbin/sliplogin, /usr/sbin/uucp/uucico, /usr/sbin/snappd, \
/bin/bash, /usr/bin/bash, /usr/local/share/bin/bash, \
/usr/local/bin/bash
Cmnd_Alias SU = /usr/bin/su
Cmnd_Alias PASS = /usr/bin/passwd root
Cmnd_Alias VISUDO = /usr/sbin/visudo
# Defaults specification
# prevent environment variables from influencing programs in an
# unexpected or harmful way (CVE-2005-2959, CVE-2005-4158,
# CVE-2006-0151)
Defaults always_set_home
Defaults env_reset
# In the default (unconfigured) configuration, sudo asks for the root password.
# This allows use of an ordinary user account for administration of a freshly
# installed system. When configuring sudo, delete the two
# following lines:
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'!
# Runas alias specification
# User privilege specification
root ALL=(ALL) ALL
# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
%ssh-susesudo ALL=(root) NOPASSWD: ALL, !SU, !SHELLS, !PASS, !VISUDO
%ssh-ict ALL=(ALL) NOPASSWD: ALL
# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now
refresh -s syslogd
# sudoers file. # # This file MUST be edited with the 'visudo' command as root. # # See the sudoers man page for the details on how to write a sudoers file. # # Host alias specification # User alias specification # Cmnd alias specification # Defaults specification # User privilege specification root ALL=(ALL) ALL # Uncomment to allow people in group wheel to run all commands # %wheel ALL=(ALL) ALL # Same thing without a password # %wheel ALL=(ALL) NOPASSWD: ALL # Samples # %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom # %users localhost=/sbin/shutdown -h now
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
# Host alias specification
# User alias specification
# Cmnd alias specification
Cmnd_Alias SHELLS = /bin/sh, /bin/bsh, /bin/csh, /bin/ksh, /bin/tsh, /bin/ksh93, \
/usr/bin/sh, /usr/bin/bsh, /usr/bin/csh, /usr/bin/ksh, \
/usr/bin/tsh, /usr/bin/ksh93, /usr/bin/rksh, /usr/bin/rksh93, \
/usr/sbin/sliplogin, /usr/sbin/uucp/uucico, /usr/sbin/snappd, \
/bin/bash, /usr/bin/bash, /usr/local/share/bin/bash, \
/usr/local/bin/bash
Cmnd_Alias SU = /usr/bin/su
Cmnd_Alias PASS = /usr/bin/passwd root
Cmnd_Alias VISUDO = /usr/sbin/visudo
# Defaults specification
# User privilege specification
root ALL=(ALL) ALL
# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
%ssh-aixsudo ALL=(root) NOPASSWD: ALL, !SU, !SHELLS, !PASS, !VISUDO
%ssh-ict ALL=(ALL) NOPASSWD: ALL
# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now
# Runas alias specification Runas_Alias USER = user-1, user-2, user-3, user-4, user-5, user-6, user-7, user-8, user-9, user-10 sjoerd ALL=(USER) NOPASSWD: /usr/bin/cp
This gives the user sjoerd the possibility to run the cp command as one of the specified users:
sudo -u user-1 cp filea fileb
This is useful when you want the new files to have the correct owner and permissions.
Discussion