Redhat: non-root user needs to copy files to a NFS share
The mount
command can only be executed as root on most Linux systems, because it has a setuid of root set. There are 2 possible work arounds using the mount
command, but they require that the root user (or somebody that can sudo
to root) make some changes.
Have them add an entry to
/etc/fstab
for the desired share. Thenoauto
option is important.vi /etc/fstab <nfs ip or FQDN>:/ /mnt/ nfs rw,noauto,user,timeo=14,hard,intr 0 0
Then have them run
mount
for the desired directorymount /mnt/
Add the user to the
suders
file, specifying use of themount
command. Please note that this is less secure, because they can essentially mount anything on the file system. Runvisudo
and add a line like this:afhood ALL=(ALL) /usr/bin/mount
Perform some form of network based copying to the remote file system such as
scp
,rcp
,ftp
,sftp
, etc. The specific command you would use is completely dependent on what the remote system allows and what you have installed on your system.
Related videos on Youtube
Sam
Updated on September 18, 2022Comments
-
Sam almost 2 years
Typically non-root users cannot mount directories.
Running Redhat Have 6GB tar.gz (/dir/somefile.tar.gz) Need to move to a NFS share on another box (//somebox/somefolder/)
We have no other access.
Any ideas?
-
vonbrand over 11 yearsNeed a lot more information... Do you have root on source, target, both? Do you have access to regular accounts on source, target, both? Can you use. e.g.
scp(1)
,rsync(1)
, ...? Can you dismount the disk from the target, connect it to the source, and copy data that way? Are the sysadmins of target, source, or both, sensitive to bribery? Blackmail? -
Bananguin over 11 yearsand why don't you mount that nfs share as root? also, most desktop environments have some setuid services so that non root users can access network shares as tell. why don't you have one of those? Obviously, you can't copy a file to an unmounted remote nfs share. so you need to figure out a way to mount that share. why do the "normal" ways not work for you?
-
-
user1106106 over 11 yearsIt should be mentioned that, to avoid errors while using
sudo
, one should usevisudo
, as it performs some syntax checking, as is explicitly stated in the manpage ofsudoers
(5).