从OpenSSH客户端删除字符

I'm writing an SSH server in Golang. Currently I have a server which can read and write from/to the client. When the client presses the delete key the server receives unicode character 13 (delete). I can rewrite the current line by sending all but the deleted character to the client. However, it only rewrites as many characters as I send. This means the last characters don't get re-written until new characters are entered. Does anyone know what the server needs to send in order for characters to be deleted from the client.

Client

Operating system: Ubuntu 16.04

Ssh version: 1.2.12

Bash version: 4.3

The answer is send a space " ".

But I suspect you are going about this in the wrong way. SSH is just a way to let a user access a terminal. It is not a command line processor. That's the job of Bash or whatever other command line the user has selected. Bash should be able to handle this type of logic as it's designed to talk to a terminal. Re-implementing bash in go-lang is a huge task and if that's what you want to do then good luck!

To avoid these problems (and make lot less work for yourself) you should be using a Pseudo Terminal to talk to bash not a pipe. If you do so then I believe bash should correctly handle backspaces for you.

You may also want to look at "Using Pseudo Terminals to Control Interactive Programs"