Access folders with sudo priviliges via Nautilius-Connect to remote server
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 ?
Solution 1:
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.
Solution 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.