sftp command to get/download .tar.gz file

get is a legal sftp command, but can't be used that way.

The correct syntax to download filename.tar.gz to your Mac is:

sftp user@host:/path/to/filename.tar.gz /some/local/folder

(Replace user with the user you use to connect to the remote server, replace host with the remote server name.)

There's nothing special to tar.gz files in the above command, it is generic to any extension.

To use get you have to enter interactive mode first:

  1. Make a connection to the remote server:

    sftp user@host
    

    Wait until >, the sftp prompt, appears in a newline - you can now type your commands.

  2. Change the remote path to /path/to:

    cd /path/to/
    
  3. Change the local path to /some/local/folder:

    lcd /some/local/folder
    
  4. Use get to download the file:

    get filename.tar.gz
    

Here another way if you are already logged into the the sftp session.

If you do a get:

sftp> get my-file.txt
get: failed to download /home/user/my-file.txt. Access is denied. 

You may considere if locally you have the permissions to write. To check where the file will be downloaded do:

sftp> lpwd
C:\Users\user1\Documents

Generally "Documents" is not permissive. So, change the download dir to C:\tmp:

sftp> lcd C:\tmp
sftp> get my-file.txt
    Downloading my-file.txt from /home/user/my-file.txt
    1% 437123KB    620KB/s 00:00:41 ETA

Done