Mount the remote file system using SSHFS

Ok, the setup is a bit confusing. Do not blame me, I am not a system administrator.

Here is the situation. There is one machine in which I can use SSH offline. I can only delete root (yes, you heard correctly) using my private key. I know that it’s more typical to register as a user and then increase privileges, but in this case I have to do the opposite.

The problem is that I want to use SSHFS to remotely mount the file system. It works fine for me. However, I do not want every file I came across to reflect root privileges. I would like to de-boost first (su for user account).

Does anyone know how I can do this using SSHFS?

+3
source share
2 answers

You can create a script to intercept the sftp subsystem call on the remote computer. Put the following script somewhere on the remote server, say / root / bin / sftp _intercept:

#!/bin/sh
exec sudo -u less_privileged_user /usr/lib/openssh/sftp-server

and then make the call as follows:

sshfs root@remote:dir mountpoint -o sftp_server=/root/bin/sftp_intercept

This should give the desired results.

You will need a suitable sudoers entry to get sudo to work without asking for a password, and don't forget “chmod 755 ~ / bin / sftp_intercept”.

Also, make sure that / usr / lib / openssh / sftp -server is indeed the path to the sftp server. If not, it might be / usr / lib / sftp-server.

+8
source

The sshfs man page states that the transfer

-o uid=$YOURUID -o gid=$YOURGID

sshfs / , , uid/gid. , .

+1

Source: https://habr.com/ru/post/1712741/


All Articles