9

I need to access the /var/logs folder & many such folders on my remote server from nautilus, using "Connect to server" via ssh. I avoid root logins & have disabled it. I would like to use sudo instead, just like I do it with SSH sessions in terminal. How can I have nautilus use sudo on the remote server to gain access? (Root login is disabled on server)

If not nautilus itself, are there any alternates that may help accomplish this ?

  • To all the dear downvoters.. & those who marked this as duplicate.. this is a different question. I need to access files/folders on a remote machine as sudoer of that machine not on the client machine. – Rajat Gupta Mar 11 '14 at 13:44
  • Can you be more specific about your errors? – Seth Mar 11 '14 at 16:22
  • Kind of a silly question. You are saying that you can't get root access because you... disabled root access. Re-enable it. – psusi Mar 11 '14 at 17:24
  • @psusi: Nope, I am not demanding root access.. I being a sudoer on remote machine want to access folders with sudo privelges via nautilus (or anything else as an alternate).. IMHO that doesn't mean I want root access, or does it ? – Rajat Gupta Mar 11 '14 at 17:42
  • Yes, sudo means do this as the super-user ( root ). Are you saying that you can sudo on the server manually, you just need to get nautilus to use it when connecting to the server? – psusi Mar 11 '14 at 18:49
  • yes, now you get it very right! – Rajat Gupta Mar 11 '14 at 18:54
  • if not nautilus itself, are there any alternates that may help accomplish this ? – Rajat Gupta Mar 11 '14 at 18:54
  • Let's fix your question so that it actually asks that then shall we? – psusi Mar 12 '14 at 13:29

5 Answers5

6

Obviously running Nautilus as your local root account (with sudo, gksu, etc) isn't going to give you root access on the server.

The problem is that the SFTP server within OpenSSH (which is what Nautilus is connecting to) doesn't support commands like sudo — it's not a shell environment. What you're asking for simple isn't possible through the standard mechanisms.

However you are not without options. I'm not sure how familiar with SSH you are but you can tunnel ports back across a connection so you could connect normally, run a simple FTP server as root and tunnel all that back to your computer over SSH. Sounds horrible but it's fairly simple.

On the server, run:

# newer Ubuntu installs:
sudo apt-get install python-pyftpdlib

# older Ubuntu installs
sudo apt-get install python-pip
sudo pip install pyftpdlib

Then from your computer, just run a short SSH command:

# If you installed with pip
ssh -tL localhost:2121:localhost:2121 -L localhost:21212:localhost:21212 user@server "sudo python -m pyftpdlib -i localhost -w -p 2121 -r 21212-21212 -d /"

# If you installed with apt-get (and pyftpdlib is pre-1.3, true in 13.10)
ssh -tL localhost:2121:localhost:2121 -L localhost:21212:localhost:21212 user@server "sudo python -m pyftpdlib.ftpserver -i localhost -w -p 2121 -r 21212-21212 -d /"

And then in Nautilus (on your computer), connect to ftp://localhost:2121. The magic of SSH will forward that over to the FTP server running as root.

There are other protocols (I've spent a while looking for a better one) but FTP is the easiest to get up and running thanks in large part to pyftpdlib. You could do similar things with webdav et al, I'm sure... It would just be a lot more hacking around.

Oli
  • 293,335
  • thanks..tried but it says: /usr/bin/python: No module named pyftpdlib.__main__; 'pyftpdlib' is a package and cannot be directly executed while authenticating to server. – Rajat Gupta Mar 14 '14 at 10:35
  • How annoying. In the apt-get installed version of pyftpdlib it seems you need a slightly different command: sudo python -m pyftpdlib.ftpserver ... – Oli Mar 14 '14 at 10:37
  • pyftpdlib.ftpserver module is deprecated This is what you get when you use apt-get (on 14.04 at least). You'll need to choose the pip way anyway – balping Apr 04 '16 at 22:02
2

If not nautilus itself, are there any alternates that may help accomplish this ?

Have you tried WinSCP? You can download a portable executable from their website and execute it using WINE.

  • Install WINE using sudo apt-get install wine
  • Download and unpack the portable executable from http://winscp.net/eng/download.php
  • Run WinSCP.exe using the context menu or run wine WinSCP.exe
  • Set the File protocol to SCP and input your Host and User name
  • Open the "Advanced" window and set the Shell option in Environment-> SCP/Shell to sudo su -
  • Login to your host
  • You can now access the logs using the internal editor or WINEs Notepad

Drag & Drop from Nautilus is also possible.

0

Launch nautilus from a terminal with gksudo nautilus.

Remember that GUI tools running with root permissions is not a good policy.

Maythux
  • 84,289
migas
  • 752
0

This might not be the best way, but just a thought, if your remote server has X11 enabled, you can simply prelaod a command

ssh -X usr@svr:~/ gksudo nautilus.

But @Oli got it covered, you can't use SFTP server within OpenSSH

Also this isn't too bad of an idea, but if you also allow your sshuser only read access to the files you need, your problem is solved.

kmassada
  • 1,376
0

I'm not sure if I am properly answering but maybe I can help a little.

ssh into your server with ssh -XC user@address

The -XC tag will pipe the window to your computer when something is opened.

Then try sudo nautilus and then your server's nautilus will open on your local screen.

Mr.Lee
  • 891