I need to read the crontab file of a shared user on a remote machine.
I cannot SSH directly to that user, but rather SSH to my private user and then run sudo -iu <shared user>
, so I can't directly run crontab -l
.
I have an SFTP connection to that user on the remote machine, but I can't read /var/spool/cron/<user>
directly, due to lack of permissions for the directory /var/spool/cron
(it seems that the crontab
executable can get the permissions to that file because it has the setuid
bit set).
SSH-ing to my user, then switching to the shared user and running crontab -l
is not optimal.
Is there any other way to achieve this?
ssh -t user@server sudo -u shareduser crontab -l
(as a single command)? – Kusalananda♦ Jun 5 '18 at 14:57