If you use MacOS, the default sftp binary does not work will when you access a Linux server – arrow keys print stuff like ^[[A, and command history does not work either.

This post suggests that MacOS’s sftp is not build with readline support. readline is a utility that handles command history, arrow keys etc.

You can get a better version of sftp through Homerew: brew install openssh. If sftp still doesn’t behave properly, make sure you address issues pointed out by brew doctor, and open a new terminal.

(page source)