I'm a newbie, trying to create an user in Ubuntu Server 22.04, with reading permissions to all existing directories and files, so it could backup everything copying them via SFTP to the backup server (that is a Windows Server 2019). I tried to apply capabilities(7) but I guess I'm doing it wrong, because the backup-user can't read directories and files that don't have "others" permissions (ex.: rwxrwx---
). What am I doing wrong? Is there any other way to create an user with "read only" permissions to all files and directories in the system?
I created the user backup-user
with:
sudo useradd backup-user -c "User to execute backups" -d /
And defined a password with:
sudo passwd backup-user
Then edited the file /etc/security/capability.conf
with:
sudo nano /etc/security/capability.conf
Adding at the end of file the line:
cap_dac_read_search backup-user
Then logged as backup-user
and tried:
cd /var/log/apache2
Receiving:
-sh: 1: cd: can't cd to /var/log/apache2
Also tried to add in the end of /etc/security/capability.conf
, instead, the line:
cap_dac_override backup-user
But got the same results.
The permissions on /var/log/apache2
directory are:
drwxr-x--- root adm
When logged as backup-user
, the result for capsh --print
is:
Current: =
Bounding set =cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,cap_wake_alarm,cap_block_suspend,cap_audit_read,cap_perfmon,cap_bpf,cap_checkpoint_restore
Ambient set =
Current IAB:
Securebits: 00/0x0/1'b0
secure-noroot: no (unlocked)
secure-no-suid-fixup: no (unlocked)
secure-keep-caps: no (unlocked)
secure-no-ambient-raise: no (unlocked)
uid=1004(backup-apesp) euid=1004(backup-apesp)
gid=1004(backup-apesp)
groups=1004(backup-apesp)
Guessed mode: UNCERTAIN (0)
When logged as a sudo
user, the result for sudo capsh --print
is:
Current: =ep
Bounding set =cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,cap_wake_alarm,cap_block_suspend,cap_audit_read,cap_perfmon,cap_bpf,cap_checkpoint_restore
Ambient set =
Current IAB:
Securebits: 00/0x0/1'b0
secure-noroot: no (unlocked)
secure-no-suid-fixup: no (unlocked)
secure-keep-caps: no (unlocked)
secure-no-ambient-raise: no (unlocked)
uid=0(root) euid=0(root)
gid=0(root)
groups=0(root)
Guessed mode: UNCERTAIN (0)