6

When using sftp from a Mac to an Ubuntu machine arrow keys, backspace and tab completion do not work. Specifically, arrows keys and backspace result in character sequences and tab just inserts a tab. However, when using sftp from the Ubuntu machine to the Mac, I have no issues. I cannot figure out where the difference is. My goal is to be able to sftp into the Ubuntu machine and use arrow keys, backspace, and tab completion.

SHELL:

I have tried both zsh and bash on both machines (Upgrading from /bin/sh is the fix suggested on most other similar questions)

SSHD_CONFIG:

I have tried both Subsystem sftp /usr/lib/openssh/sftp-server and Subsystem sftp internal-sftp within the sshd_config file on the Ubuntu machine. The Mac is using /usr/libexec/sftp-server.

I realize that these settings are different so I suspect this causes the difference, but I do not know enough to understand precisely what this difference is nor how I could resolve it. I also cannot find much documentation on what these different sftp servers are.

Thank you for any advice!

0

3 Answers 3

6

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/bin/scp
/usr/local/Cellar/openssh/8.4p1_2/bin/sftp
/usr/local/Cellar/openssh/8.4p1_2/bin/slogin
/usr/local/Cellar/openssh/8.4p1_2/bin/ssh
/usr/local/Cellar/openssh/8.4p1_2/bin/ssh-add
/usr/local/Cellar/openssh/8.4p1_2/bin/ssh-agent
/usr/local/Cellar/openssh/8.4p1_2/bin/ssh-keygen
/usr/local/Cellar/openssh/8.4p1_2/bin/ssh-keyscan
/usr/local/Cellar/openssh/8.4p1_2/libexec/ (4 files)
/usr/local/Cellar/openssh/8.4p1_2/sbin/sshd
/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
    Commented Jan 31, 2021 at 16:52
1

with-readline is a small program that allows the GNU Readline library to be used with arbitrary programs, without having to recompile those programs. It is useful for improving the user interface of simple terminal-based programs which for whatever reason have not been modified to use Readline themselves.link

You can install with-readline to support arrow keys and backspace.
However,tab is only supported on local side, you can not complete filename from remote side.
Installation as detail below:

brew install with-readline
echo 'alias sftp="with-readline sftp"' >> ~/.zshrc
3
  • 1
    Thanks for the suggestion. Any ideas for also tab completion? It works when sftping into Mac, so it ought to be possible... Commented Apr 26, 2020 at 23:00
  • @user3167101It depends on how the SFTP software programmed,the official one clearly doesn't support these features. When you sftping into Mac,for instance,from windows,then actuallly you use the SFTP software programmed for windows.SFTP software has different versions,maybe you can try the third party one.
    – fjh1997
    Commented May 1, 2020 at 8:44
  • 1
    @user3167101 see superuser.com/a/1622315/965558 it's a better answer
    – 傅继晗
    Commented Jan 31, 2021 at 16:25
0

Good news! sftp (OpenSSH) has a build configure option to enable editline (readline history) support. I cannot possibly fathom WHY any sane person would build it without this, as it gives all the crucial features you seek (up-arrow command history, tab-completion of local and remote filenames, etc.) with zero caveats. I enabled it when I built OpenSSH 8.7p1 on my jailbroken iPad but I'm sure it works equally well anywhere.

You must log in to answer this question.

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