Thanks for the response Mike! What ended up working for me is not supporting PTY. As soon as I returned -1 in the PTY callback, I got the behavior i wanted!
Charles A. Barbe Senior Software Engineer Allworx, a Windstream company 245 East Main St | Rochester NY | 14604 [email protected] | 585.421.5565 ________________________________________ From: Mike Jones [[email protected]] Sent: Thursday, August 07, 2014 10:44 PM To: [email protected] Subject: Re: help with simple ssh shell server I did something similar and found this to work well enough. buf[0] is the character that was entered. c is the number of characters collected so far on the current input line. cmd[] is where it accumulates what has been typed so far. What it does depends on whether the cursor is currently at the beginning of a line or there is already some text entered. Either way, sending '\b' will just move the cursor. So to get rid of a character, you back up one character, then replace it with a literal space and then back up again so the next character entered will be where you expect it. if ( (buf[0] == 0x7f || buf[0] == CTRL('H')) ) { if ( c > 0 ) { cmd[--c] = 0; // back up, space over the character, then back up again ssh_channel_write(channel, "\b \b", 3); } else // clear any visible character // there is a prompt shown, so we don't allow backing up any farther than that ssh_channel_write(channel, " \b", 2); // fix the client side } Mike Jones On 8/7/2014 1:41 PM, Barbe, Charles wrote: > Hi, > > I am attempting to implement a very simple ssh shell server for use on an > embedded platform that has a custom shell. I am able to successfully > establish the connection, take in commands and spit out the results. My > question though is how does one handle echoing command inputs correctly, > particularly with respect to the backspace key. > > Currently, my echoing is just going through my normal stdout - with a > "printf("%c", character) as each character is received - which is being > written out to the ssh channel. But this does not seem to work with things > like the backspace key. > > Am i missing something? > > Thanks for any help you can provide! > > Charles A. Barbe > Senior Software Engineer > Allworx, a Windstream company > 245 East Main St | Rochester NY | 14604 > [email protected] | 585.421.5565 > >
