2
I have a remote server that I can SSH into. I want to mount a folder that's on that server onto my local linux desktop. Then I want to be able to read/write files there from within my text editor. How do I do this?
One IMPORTANT requirement:
- The remote server does not allow root login
- The folder on the remote server is root only
Normally when I ssh, I login as the basic user and then do an "su" to do root actions. How would I do this with sshfs?
Server: CentOS 6.5
Desktop: openSUSE 13.1
I've never attempted it, but try Googling SMB over SSH. – Spencer5051 – 2014-01-30T21:08:59.700
Look into SSHFS.
– nerdwaller – 2014-01-30T21:09:54.117@nerdwaller Does that work with the ssh requirements (I just updated my post)? The ssh server doesn't allow root login, so I have to login as basic and then do an "su" – Don Rhummy – 2014-01-30T21:12:28.057
Possibly, I think you may need to utilize a solution similar to this one in that case.
– nerdwaller – 2014-01-30T21:15:03.843Check out How do I sudo over sshfs? too.
– Robertof – 2014-01-30T21:15:25.453@Robertof Thank you, can you explain a bit more about that command? I'm not sure I understand the answer, which uses the
-o
option:sshfs login_user@host:remote_path local_path -o sftp_server="/usr/bin/sudo /usr/bin/sudo -u as_user /usr/lib/ssh/sftp-server"
– Don Rhummy – 2014-01-30T21:50:13.403@Robertof since my remote is CentOS, would it be:
sshfs basicuser@remotehost:remote_path local_mount_path -o sftp_server="/usr/bin/sudo -u root /usr/libexec/openssh/sftp-server"
? Do I have all those pieces correct? – Don Rhummy – 2014-01-30T21:55:49.223You don't need the
-u root
parameter,sudo
will default to root. However, keep in mind thatsudo
requires a password and sshfs won't ask you to input it. You either need to setup in thesudoers
a NOPASSWD to spawn the server for your user, or to reset thenotty
parameter as explained in the linked answer. – Robertof – 2014-01-30T21:58:06.073@Robertof thanks! does everything else look correct? And will that allow me to read/write to that folder on my local system as the user I'm mounting with (not basicuser but my local user)? – Don Rhummy – 2014-01-30T21:59:13.523
Yes, it should. – Robertof – 2014-01-30T22:01:00.617
@Robertof Is there no way to pass the password into the sudo command? – Don Rhummy – 2014-01-30T22:01:35.953
I was referring to the fact that you need to authenticate sudo, as explained in the other question. Also that will allow you to execute an sshfs session as root but without directly logging as root (since you said that it isn't allowed in that server). Instead, it will execute the SFTP server as root with sudo. (by the way since superuser is warning me - should I convert this as an aswer?) – Robertof – 2014-01-30T22:05:34.570
@Robertof Yes, please change to an answer (use the code string in my above comment with your changes) and I'll continue this conversation there - I have another question... – Don Rhummy – 2014-01-30T22:07:30.430
Ok, let me write it and then I'll answer your other questions. – Robertof – 2014-01-30T22:08:37.800