I use Terminal.app constantly. When connecting via ssh to remote *nix systems, I can continue to use tab to complete command names and arrow-up/down to navigate the command history. However, with sftp this does not work, and I get [-escaped sequences for the latter and a literal tab for the former.

Any way to get this to work? Anything to do with readline?


4 Answers 4


Check out with-readline. There's an example using sftp there.

  • 3
    Only problem is it's shows password.
    – shantanu
    Feb 14, 2017 at 6:54
  • 3
    .. and it completes based on the local folder, not the remote folder Jan 10, 2018 at 18:28

Having tried to install with-readline on OSX 10.7.5 I ran into linker errors.

While trying to find a solution to this problem I discovered that MacPorts has a port of OpenSSH which includes the sftp utility compiled with readline support. MacPorts also sets this version of sftp as the default.

  • 4
    The same solution can be applied if you prefer Homebrew, their version of homebrew/dupes/openssh also comes with tab completion. Jul 5, 2016 at 13:21

You can also try yafc.


Type this into the Terminal:

which sftp

If the result were /usr/bin/sftp, means you are using the macOS built-in SFTP version that is out of date compared two the GNU version. More details here.

You could install the Homebrew version — which is the GNU version — instead

brew install openssh

And list the openssh install path:

brew list openssh

Tou would see some binary here for example:

/usr/local/Cellar/openssh/8.4p1_2/.bottle/etc/ (12 files)
/usr/local/Cellar/openssh/8.4p1_2/libexec/ (4 files)
/usr/local/Cellar/openssh/8.4p1_2/share/man/ (15 files)

Now type:

which sftp

the result would be /usr/local/bin/sftp,which is a soft link of /usr/local/Cellar/openssh/8.4p1_2/bin/sftp

Then try the Homebrew version of SFTP and enjoy it!

  • 1
    Please do not post the same answer to multiple questions. If the same information really answers both questions, then one question (usually the newer one) should be closed as a duplicate of the other. You can indicate this by voting to close it as a duplicate or, if you don't have enough reputation for that, raise a flag to indicate that it's a duplicate. Otherwise tailor your answer to this question and don't just paste the same answer in multiple places.
    – DavidPostill
    Jan 31, 2021 at 16:52
  • 2
    @DavidPostill Thank you! I'm a newbee and not familier with this.
    – 傅继晗
    Feb 1, 2021 at 3:55
  • Bear in mind that with the standard OpenSSH (as opposed to the one that is shipped with macOS) you won't be able to save passwords for SSH keys in the macOS Keychain. Jun 8, 2022 at 13:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .