Using gvfs to access remote servers via FTP/SFTP
Using the Gnome virtual file system (gvfs) packages allows us to access remote servers from the linux userspace GUI environment via FTP/Obex/SSH/WebDAV/WebDAVS/Samba
- The gigolo package allows management of the gvfs mounts using a GUI application. If not installed with your distro, you can install it from the base repositorities using either :
# sudo apt-get install gigolo for debian/ubuntu
# yum -y install gigolo for red hat/centos/fedora
- Starting gigolo – Look for the launcher for gigolo under the System (debian) /System Tools (red hat/centos) menu category. To get started click Connect.
- Choose which protocol you want to use to mount your remote file system . Supported options are FTP/Obex/SSH/WebDAV/WebDAVS/Samba. For my system, I want to mount my remote Digital Ocean web server, so I select SSH , and then enter my SSH username and port . Once I click Connect, my new gvfs bookmark appears in the right pane  and double clicking on it opens up the mounted file system in nautilus .
- Great! Now that the file systems are mounted up, you can use the GUI tools to navigate the remote file systems, modify files, etc. But what if you’re a command line junkie?debian: from the shell,I can cd to $XDG_RUNTIME_DIR/gvfs to get to my mounted remote file systems.
glaw@fedora:1000$ cd $XDG_RUNTIME_DIR/gvfs glaw@fedora:gvfs$ ls sftp:host=web2.XXXXXX,port=XXX,user=root glaw@fedora:gvfs$ cd sftp\:host\=web2.XXXXX\,port\=XXXX\,user\=root/ glaw@fedora:sftp:host=web2.XXXXX,port=XXXX,user=root$ ls -lart total 524 drwx------ 1 glaw glaw 16384 Jul 8 2014 lost+found -rw-r--r-- 1 glaw glaw 0 Jul 8 2014 .autorelabel drwxr-xr-x 1 glaw glaw 4096 Aug 12 2015 srv drwxr-xr-x 1 glaw glaw 4096 Aug 12 2015 mnt drwxr-xr-x 1 glaw glaw 4096 Aug 12 2015 media drwxr-xr-x 1 glaw glaw 4096 Feb 29 2016 usr drwxr-xr-x 1 glaw glaw 4096 May 16 11:25 opt dr-xr-xr-x 1 glaw glaw 4096 Jul 5 08:54 lib drwxr-xr-x 1 glaw glaw 4096 Aug 1 03:38 backup drwxr-xr-x 1 glaw glaw 4096 Sep 24 23:14 home dr-xr-xr-x 1 glaw glaw 0 Sep 25 01:11 proc dr-xr-xr-x 1 glaw glaw 0 Sep 25 01:11 sys drwxr-xr-x 1 glaw glaw 4096 Sep 25 01:11 var drwxr-xr-x 1 glaw glaw 2880 Sep 25 01:11 dev dr-xr-xr-x 1 glaw glaw 4096 Sep 25 01:11 . dr-xr-xr-x 1 glaw glaw 4096 Sep 25 01:11 boot drwxr-xr-x 1 glaw glaw 4096 Oct 24 13:35 etc dr-x------ 3 glaw glaw 0 Oct 25 13:15 .. dr-xr-xr-x 1 glaw glaw 36864 Oct 26 13:56 lib64 dr-xr-xr-x 1 glaw glaw 36864 Oct 26 13:56 bin dr-xr-x--- 1 glaw glaw 4096 Oct 26 14:00 root dr-xr-xr-x 1 glaw glaw 12288 Nov 1 08:41 sbin drwxr-xr-x 1 glaw glaw 4096 Nov 6 20:53 scripts drwxr-xr-x 1 glaw glaw 680 Nov 7 00:00 run drwxrwxrwx 1 glaw glaw 372736 Nov 7 14:04 tmp
- Connecting from the command line
The Linux GUI is nice but it is also to mount this up via the command line.
debian: # sudo apt-get install sshfs red hat: # yum install sshfs # sshfs -p 1234 root@web2.XXXXX.com:/ /path/to/mount To enable this at login, you can also add the following to your GUI user's crontab : # crontab -e @reboot sshfs -p 1234 root@web2.XXXXX.com:/ /path/to/mount
Ok, that’s great but what are the uses?
As a web developer occasionally I have to try to track down where a certain CSS class definition is or where a PHP function is. When I haev SSH access, this is no problem, but with FTP only, it makes it much more difficult unless I want to mirror a full website on my local computer. With a gvfs FTP mount, it makes it easy to cd over to the mount point and then use the handy dandy grep command to find what I am looking for :
# grep -r myCSSClass ./