I am using SFTP to download files from a server. It connects to the server fine and when I enter ls it lists all the files I am looking for.

When I get to the: sftp>, I enter: get [FILENAME]

and then it says:

Fetching /directory/FILENAME to FILENAME
/directory/FILENAME 100%

then it takes me back to: sftp>

I have searched for the file on my computer but I cannot find it. I think the second directory it shows should be the local directory I want the file to be downloaded to right? If so how do I change it?


If you do not specify target path in get command (as the second argument), the OpenSSH sftp downloads the file to the current working directory. That path is not shown anywhere in the output (only file name is in this case).

The output of get is like:

Fetching <1st_arg_of_get=remote_path> to <2nd_arg_of_get=local_path_or_filename_only_if_no_2nd_arg>
<1st_argument_of_get=remote_path>  xxx% sizeKB ....

So generally, you should find the downloaded file in the same path you have started sftp from (= current local working directory). To see the local working directory use command lpwd in sftp. You can also use lcd to change the local working directory.

(I assume your local computer is *nix and the sftp is OpenSSH.)

  • 1
    In most SFTP clients, you can issue the lpwd command which will return the client's local working directory. That should be the calling shell's working directory, but it may not be. You can also use lcd to change the local directory and lls to get the local directory's contents.
    – Bacon Bits
    Oct 27 '14 at 19:24
  • @BaconBits Thanks for the comment. I have included this to the answer. Oct 27 '14 at 19:39
  • Additionally, you can usually use ! in your ftp/sftp client to escape to the shell. !pwd and/or !ls would be particularly useful here. Oct 27 '14 at 19:54
  • Thank you all so much for your help! I really appreciate it! Everything makes sense now :)
    – Mo Gaucho
    Oct 27 '14 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.