What is SFTP?
SFTP is the Secure File Transfer Protocol whose primary use is secure sharing of files and data within or between organizations. It’s been around for quite some time and most IT folks and developers love to use it for integration and automation purposes.
What does ‘mounting a drive’ mean?
Mounting a drive is simply the setting up of a disk resource so that it is recognizable to your local operating system. Once the resource is mounted, you can then access it just like you would any directory or folder. Mountable resources may include internal hard drives, external hard drives, USB sticks, network drives, and more.
Why should I mount an SFTP as a drive on Mac?
The advantages of mounting an SFTP server as a drive include the ability to utilize Finder to explore the SFTP files and perform a number of actions on them such as copying, moving, deleting, and opening.
Before we even start, make sure you have access to an SFTP server. If you don't have one, you can set one up quickly on SFTP To Go.
- Open the Terminal (Open Spotlight, type in
terminaland hit return)
- Install OSX Fuse and SSHFS by typing in the following commands one after the other (you may be asked to provide your password to proceed with setup):
brew cask install osxfuse brew install sshfs
- To mount the SFTP server as a drive, use the following command. Replace the username, hostname, and remote path with your SFTP username, hostname and remote path. Then, replace localpath with the local path you’d like the SFTP files to show up as and provide a distinct name for the volume (e.g. sftp). Important: the localpath should be a nonexistent name under an existing directory (e.g. /Users/john/Desktop/sftp)
sshfs username@hostname:/remotepath /localpath -ovolname=sftp
If you’re authenticated using a password, a prompt will now ask you to provide it in order to continue.
At this point you may be asked to allow sshfs permissions at the operating system level, so go ahead and do so!. Once you have given the OK, you can browse your SFTP files as if they were an innate part of your computer.
And… that’s it! By following these few simple steps, you will have a number of new abilities and advantages, making SFTP an even more friendly system to use.
Now that I got on the horse, how do I dismount?
To unmount the SFTP server, simply run the following command and replace localpath with the local path you mapped the SFTP to:
umount -f /localpath