LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 02-10-2014, 04:45 PM   #1
postcd
Member
 
Registered: Oct 2013
Posts: 527

Rep: Reputation: Disabled
Post SSHFS: How to mount remote directory of the root to non root user?


Hello,

im faiting with sshfs and fuse.

On local server im user "amnesia" (i have root privileges too when needed)
im "mounting" remote directory of the remote server using SSHFS program.

Im loging to root account on remote server... like:

sshfs root@remoteserverip:/remotedir /localdir

it appears that all folders/subfolders and files inside that mounted directory has root privileges (which seems correct because im mirroring an remote directory of an "root user"..), so i cant remotelly for example delete them being user "amnesia" (i cant do it from GNOME, but from terminal i can, still loged in as amnesia), not sure why.

Please how can i gain permissions to modiffy, create, delete in that mounted SSHFS folders as an local "amnesia" user?

permissions:


Code:
amnesia@amnesia:~/sshfs$ stat docs
File: `docs'
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 17h/23d Inode: 612 Links: 1
Access: (0700/drwx------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2014-02-10 22:21:12.000000000 +0000
Modify: 2014-02-10 22:20:39.000000000 +0000
Change: 2014-02-10 22:20:39.000000000 +0000


Code:
amnesia@amnesia:~/sshfs$ stat truecrypt-7.1a-setup-x86
File: `truecrypt-7.1a-setup-x86'
Size: 2671271 Blocks: 5224 IO Block: 4096 regular file
Device: 17h/23d Inode: 418 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2014-02-10 20:36:44.000000000 +0000
Modify: 2012-02-07 10:26:40.000000000 +0000
Change: 2012-02-07 10:26:40.000000000 +0000


Code:
amnesia@amnesia:~/sshfs$ stat ../sshfs
File: `../sshfs'
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 17h/23d Inode: 1 Links: 1
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2014-02-10 21:58:23.000000000 +0000
Modify: 2014-02-10 21:56:51.000000000 +0000
Change: 2014-02-10 21:56:51.000000000 +0000



FROM "man sshfs":
Quote:
FUSE options:

-o allow_other
allow access to other users

-o allow_root
allow access to root

Quote:
-o idmap=TYPE
user/group ID mapping, possible types are:

none no translation of the ID space (default)

user only translate UID of connecting user

but when i add idmap, it returns "read: Connection reset by peer"


!!!!!!!!!!!!!!!!!!!!!!!!!!!
Quote:
THis exact command worked:
mkdir mydir7;sshfs -o idmap=user root@extserverip:/home/mydir /home/amnesia/mydir7

(first create directory, then idmap=user not to be changed to username but should levave "user"

then folder stat:
File: `mydir7'
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 15h/21d Inode: 1 Links: 1
Access: (0755/drwxr-xr-x) Uid: ( 1000/ amnesia) Gid: ( 0/ root)
Access: 2014-02-10 21:58:23.000000000 +0000
Modify: 2014-02-10 21:56:51.000000000 +0000
Change: 2014-02-10 21:56:51.000000000 +0000
!!!!!!!!!!!!!!!!!!!!!!!!!!!
here is the full tutorial on how to achieve SSHFS folder mounting.

Please anyone have idea how to fix my permissions in simple/any way?

Last edited by postcd; 02-10-2014 at 05:13 PM.
 
Old 02-11-2014, 01:35 AM   #2
postcd
Member
 
Registered: Oct 2013
Posts: 527

Original Poster
Rep: Reputation: Disabled
ssh root@serverip

returned:
ssh_exchange_identification: Connection closed by remote host

the (/etc/sysconfig/iptables) nor (/etc/hosts.deny) dont contains any parts of IP im using to access.

when running some command on root server of fail VPS im getting:
Warning: Unknown iptable module: fuse, skipped
Unable to fork: Cannot allocate memory

that failing virtual server config file /etc/sysconfig/vz-scripts/VMID.conf contains:
Quote:
IPTABLES="ip_tables iptable_filter iptable_mangle ipt_limit ipt_multiport ipt_tos ipt_TOS ipt_REJECT ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_LOG ipt_length ip_conntrack ip_conntrack_ftp ipt_state iptable_nat ip_nat_ftp fuse"
DEVNODES="fuse:rw "
tried to restart VPS, an dgot another interesting data:
[root@* sysconfig]# vzctl restart 190
Quote:
Warning: Unknown iptable module: fuse, skipped
Restarting container
Stopping container ...
Container was stopped
vzquota : (error) Quota off syscall for id 190: Device or resource busy
vzquota : (error) Possible reasons:
vzquota : (error) - Container's root is not unmounted
vzquota : (error) - there are opened files inside container's root/private area
vzquota : (error) - your current working directory is inside a container directory
vzquota : (error) root/private area
vzquota : (error) Currently used file(s):
/home/vps/190/etc/sysconfig
vzquota off failed [3]
so it failed to restart VPS, so i removed fuse mentionings froma bove mentioned .conf file, then restart and also initial commnad "ssh root@serverip" started working.

if anyone have idea how to prevent this fuse error in future? here is the same issue said in another words

Last edited by postcd; 02-11-2014 at 02:45 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
NFS setup to access directory from a remote machine as non-root user suraj278 Linux - Server 3 03-06-2012 09:00 PM
sshfs file system mount username and root on single line jsaravana87 Linux - Server 1 11-24-2011 10:20 AM
Limit mount points of SSHFS to just user's home directory GATTACA Linux - Software 4 04-24-2010 09:20 AM
Mount sshfs as root using sudo maxmil Linux - Newbie 2 01-05-2010 03:43 AM
no-root user can not mount a remote nfs directory? xiamw Linux - General 3 12-16-2004 09:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 12:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration