Transferring Files with SFTP

SFTP

SFTP is a protocol that allows a client program running on one computer to establish a secure communication channel with a server program running on a remote host and transfer files from one machine to the other.  In order for a user to establish an SFTP connection to a remote host, they must possess valid login credentials on the remote machine.

On Windows

Filezilla is a time-tested GUI-based SFTP client that allows a user to transfer files between a local computer and a remote host.  The software can be downloaded from their download page.  For Windows users the win64-setup.exe file is recommended.  Just download and install.

Below are basic instructions on how to use Filezilla using the Quickconnect bar.  Please consult the user documentation or information on all of the features available in Filezilla.

To connect to a remote host, in the Host field type sftp://hostname where hostname is the domain name or IP address of the host you are trying to connect to.  Then enter your username and password in their respective fields and press the Quickconnect button.

Once a connection is established, the file system for your local machine is accessible from the file system tree in the bottom left pane and the file system for the remote host is accessible from the file system tree in the bottom right pane.  Files can be transferred from one computer to the other by simply dragging and dropping the files.

On MacOS

Filezilla is also available to MacOS users, but don’t be silly and download it – you are much better than that.  You are a master of all things UNIX and so you, like I, transfer files directly from the Terminal application.

To establish a SFTP connection with a remote host from the terminal app’s command line, enter the following command sftp username@hostname where username is the username on the remote computer and hostname is the domain name or IP address of the remote computer.  As with the ssh command, you may be asked if you trust the host.  If so, type Yes and press enter.  When you are prompted for a password, enter the host password and press enter.

After your credentials have been verified you’ll see an ftp prompt.  From there you can issue ftp commands.  Type help to see a list of all of the ftp commands available.  You’ll most likely, however, only need the following commands: ls, lls, cd, lcd, get, and put.

  • At any point in time, the sftp program keeps track of your current working directory on your local machine (initially the directory you where in when you launched the sftp program from the command line) and your current working directory on the remote machine (usually your home directory).  Files are transferred from the current working directory of one computer to the current working directory of the other computer.
  • To view and change the current working directory of the remote host you can use the ls and cd commands, respectively.
  • To view and change the current working directory of the local machine you can use the lls and lcd commands, respectively.
  • To transfer a file from the remote machine to the local machine enter get filename where filename is the name of the file that you wish to transfer.
  • To transfer a file from the local machine to the remote host, enter put filename where filename is the name of the file that you wish to transfer.