How to Access Your Web Hosting via the Command Line with SSHFS¶
For practical reasons, you may wish to use the command line to manage your files with common commands (ls
, cp
, mv
, ln
…) and using utilities like grep
and sed
.
In addition to being able to access your web hosting via ssh, you can also manage your files via command line with sshfs
. This will allow you to mount the remote directory of a web hosting on your local machine.
sshfs
can usually be installed using your preferred package manager.
Note
The sshfs utility uses ‘FUSE’, a framework initially intended for POC (Proof of Concept). This tool can sometimes be unstable. For more information on FUSE, see https://fuse.sourceforge.net/.
Create a Directory for Mounting¶
To begin, we will create the directory to mount:
alx@desktop:~$ mkdir SimpleHosting
Connect to the Remote Directory¶
Once the directory is created, connect to the remote directory using sshfs.
In a terminal window, type:
alx@desktop:~$ sshfs login@sftp.sd3.gpaas.net:/ SimpleHosting/
You will then be asked to enter the SFTP password. Once connected, simply navigate to the mounted directory. You can now use the command line as usual.
alx@desktop:~$ cd SimpleHosting/
alx@desktop:~/SimpleHosting$ ls -l
total 32
drwxr-xr-x 1 root root 8 2011-10-14 17:50 ./
drwxr-xr-x 38 alx alx 4096 2012-03-25 16:15 ../
drwxrwxr-x 1 root 5100 7 2012-03-13 14:45 lamp0/
drwx------ 1 5000 5000 2 2011-09-13 17:03 private/
-rw-r--r-- 1 root root 1064 2011-10-14 17:50 README.txt
lrwxrwxrwx 1 root root 13 2011-10-14 17:50 snapshot -> .zfs/snapshot/
drwx------ 1 5000 5000 3 2012-03-12 22:39 .ssh/
lrwxrwxrwx 1 root root 16 2011-10-14 17:50 vhosts -> lamp0/web/vhosts/