When working with remote Linux servers, file transfer is a common scenario for developers. This doesn’t need to be a hassle. Secure and convenient access to directories can be done with sshfs.
Installing SSHFS
Install sshfs with your favorite package manager.
Ubuntu/Debian
sudo apt-get install sshfs
Archlinux
sudo pacman -S sshfs
CentOS/Red Hat
sudo yum install sshfs
Windows
win-sshfs is available from the Google Code Archive.
https://code.google.com/archive/p/win-sshfs/
Mac OSX
Mac will require FUSE as well as SSHFS and is available at https://osxfuse.github.io
Mounting The Remote File System
First create the local directory you would like to access the remote files from.
mkdir /pathto/somedirectoryname
Then mount with sshfs.
sshfs user@ip.address:/pathtoshare /home/user/directory/to/share/to
If you are using key authorization such as when connecting to a remote server like an Amazon EC2 instance, you will need to specify the full path of the key file with the IdentityFile option. Setting the allow_other option will be required as well.
sshfs user@ip.address:/pathtoshare /home/user/directory/to/share/to -o IdentityFile=/home/user/full/path/to/keyfile.pem -o allow_other
Unmounting The Remote File System
sudo umount /pathto/somedirectoryname
Permanently Mounting A Remote File System
/etc/fstab file.sudo vi /etc/fstab
Append another entry with the sshfs setting:
sshfs#user@xxx.xxx.xxx.xxx:/ /pathto/somedirectoryname
To load these settings, you can either reboot the machine or reload fstab mounts with the command
mount -a
Usage
The directory and their files will now be available locally as if they originated from your system. This will make file transfer and development a hassle free and much easier experience.