Connect to your Linux server with SFTP

When you need to transfer files to and from your cloud server, Secure File Transfer Protocol (SFTP) is one of the simplest and most popular methods. Unlike standard FTP, which transmits your data in a plainly readable format and exposes you to security risks, SFTP is conducted over an encrypted session via an SSH connection. This article will show you how to connect to your Linux server through SFTP.


In order to follow this guide, you’ll need the following:

  • A user on your cloud server with permissions to log in over SSH
  • Port 22 must be open to allow traffic from your local machine (or if SSH uses a custom port number, that port must be opened)
  • (Optional but recommended) A utility program installed on your local machine that supports SFTP

Connecting With Filezilla

The simplest method to transfer files over SFTP, especially for beginners, is to use one of the utility programs available for Windows and Mac OS. Filezilla is a popular, free, and open source SFTP client and the one we will be using in this guide. However, other SFTP clients such as Cyberduck or WinSCP can be used. These clients add a graphical interface which makes it simpler to navigate both your local files and the server files at once, as well as work more easily with transferring multiple files.

1. Input your IP address, user name, password, and port 22

2. Click Quickconnect

You’ll now be able to send files to and from your Linux server, and Filezilla will support additional desktop features such as selecting multiple files, or drag and drop.

Connecting through the SFTP command line tool

There may be situations where you’re unable to load an additional SFTP utility onto your local device, or perhaps you want to transfer files from server to server. The sftp command line tool is available through all major Linux distributions, the Mac OSX terminal, and even Windows 10 now includes an OpenSSH client accessible through the command prompt that includes sftp capabilities.

1. Log in using the sftp command

The sftp login is similar to how you would connect using SSH. Use the following command replacing username with your specific username, and your_server_ip with the server’s correct IP:

sftp username@your_server_ip

2. Downloading files

Downloads will automatically go to whichever directory you were in locally in your terminal or command prompt session. Use the get command like so:

get /path/to/server/file

Or to download to a specific directory (Windows local paths use a backslash, Linux and Mac paths will use forward slash same as the server path):

get /path/to/server/file C:UsersAdminsomefolder

get /path/to/server/file /Users/Macbookuser/Downloads

3. Uploading files

Uploading is done with the put command, followed by the local file path first and the destination on the server second.

put C:UsersAdminsomefoldersomefile /path/to/server/dir

put /Users/Macbookuser/Documents/somefile /path/to/server/dir

4. Additional tips for using the command line

Many home desktop computers are much more friendly towards file names containing spaces, whereas most command line tools are less forgiving. If you want to transfer a file with a space within the file name, simply encase it in double quotes like so:

put "C:Program Files (x86)somefile"

Performing large file transfers may sometimes get interrupted, but you can resume those transfers by replacing your previous get command with reget, or put command with reput:

reget /path/to/server/file /Users/Macbookuser/Downloads

reput /Users/Macbookuser/Documents/somefile /path/to/server/dir

5. Ending your SFTP session

When you’re done with the SFTP shell run the following command:


Leave a Reply

Your email address will not be published. Required fields are marked *