Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Secure Shell

Reply
 
Thread Tools Display Modes
  #1  
Old 01-26-2012, 12:02 PM
Jakiao Jakiao is offline
Registered User
 
Join Date: Jan 2012
Posts: 4
Strange Behavior in SSH

Heya,

I'm having a weird problem with how SecureCRT (latest, x64) interacts with a CLI I work with on a CentOS machine.

When connecting to mongo/mongos CLI the keyboard begins acting strange. This issue does not happen with other SSH programs (i.e. PuTTY).

In the following example, I have tried to backspace a few characters. The following happens:

mongos> db.metrics.find({'$regmongos> db.metrics.find({'$re mongos> db.metrics.find({'$r mongos> db.metrics.find({'$

My original line was: mongos> db.metrics.find({'$reg

Backspacing g, e, and r resulted in the line shown in the example.

Rather than just deleting the previous char, it deletes the char, tabs, and redraws the remainder of the line again and again. I can still send my input normally, but the display is all messed up.

I've been looking all over my settings and keymap to try and find a fix, but to no prevail. Anyone experience this before?
Reply With Quote
  #2  
Old 01-26-2012, 12:12 PM
Jakiao Jakiao is offline
Registered User
 
Join Date: Jan 2012
Posts: 4
Hm, no edits allowed I see. Okay to add details: Same thing happens if you try to use the left and right arrow keys, but it's even more confusing then to figure out what SecureCRT is showing you.
Reply With Quote
  #3  
Old 01-26-2012, 01:06 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
Hello Jakiao,

Sometimes a client and server aren't in agreement about what a key-press means. This can have unexpected consequences. Emulation (and keyboard emulation) can make all the difference.

Which emulation is set in Session Options / Terminal / Emulation?

What do you see when you run the command echo $TERM on the server?

Can you connect with SecureCRT and run the command stty -a on the server, then post the output?

If you type cat -v on the remote and then press the Backspace key, left arrow, right arrow, what do you see with SecureCRT and PuTTY?
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #4  
Old 01-26-2012, 01:49 PM
Jakiao Jakiao is offline
Registered User
 
Join Date: Jan 2012
Posts: 4
Quote:
Originally Posted by miked View Post
Hello Jakiao,

Sometimes a client and server aren't in agreement about what a key-press means. This can have unexpected consequences. Emulation (and keyboard emulation) can make all the difference.

Which emulation is set in Session Options / Terminal / Emulation?

What do you see when you run the command echo $TERM on the server?
Server is VT100 and so is SecureCRT. Putty runs xterm.

Quote:
Originally Posted by miked View Post
Can you connect with SecureCRT and run the command stty -a on the server, then post the output?
speed 38400 baud; rows 47; columns 182; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts -cdtrdsr
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

Quote:
Originally Posted by miked View Post
If you type cat -v on the remote and then press the Backspace key, left arrow, right arrow, what do you see with SecureCRT and PuTTY?
Backspace/Up/Down/Left/Right in SecureCRT is ^H^[[A^[[B^[[D^[[C

On Putty Backspace works as backspace, and the arrow keys are the same as SecureCRT.

----

Switching SecureCRT to use xterm instead of VT100 fixes the problem.
Reply With Quote
  #5  
Old 01-26-2012, 02:26 PM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,040
Quote:
Switching SecureCRT to use xterm instead of VT100 fixes the problem.
Thanks for posting the solution!
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
  #6  
Old 01-26-2012, 03:16 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 930
If using the Xterm emulation solves the problem, it points to the possibility that the value of the PS1 environment variable might be a factor in causing the behavior you reported.

If you're using the bash shell (as indicated by the SHELL environment variable -- type 'set' command alone to get a listing of your environment variables and their values) on fairly recent versions of CentOS, the bash shell uses the PROMPT_COMMAND environment variable to determine how to display the shell prompt for an Xterm terminal; otherwise, PS1 is typically used to control shell prompt behavior for other terminal types.

Since PS1 is the environment variable controlling how the prompt is displayed when bash is communicating with a VT100 terminal, it's possible that your PS1 value might contain garbage/incomplete escape characters or other "properties" that lead to the exciting behavior you described.

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
  #7  
Old 01-27-2012, 01:29 PM
Jakiao Jakiao is offline
Registered User
 
Join Date: Jan 2012
Posts: 4
Unfortunately the strange behavior is not stopping there. I've come across another instance of this and it doesn't matter which terminal I use it won't resolve.

In SSH, start a screen session and switch to it. Backspace deletes the whole line instead of one character, and Delete does absolutely nothing. In this case, Backspace does not output ^H in cat -v; instead, it maintains the behavior of deleting the whole line.

This is all very peculiar. I have used SecureCRT off and on for about a decade now and this is the first time I've ever had these problems.

Edit 1: Saw Jake's reply after submitting this one. Very interesting. Something I will look into.

Edit 2: Running CentOS 5.5-5.7 using /bin/bash on the devices I'm having this problem with. All use $PS1 with the contents: [\u@\h \W]\$. Everything is fine and dandy with backspace until I switch to a screen session. $TERM changes to 'screen' and $PS1 remains unchanged.

Also worth noting, Jake, is that the original weird behavior I reported was occurring inside a program launched from bash. I haven't seen the corrupted output in bash directly.

Last edited by Jakiao; 01-27-2012 at 01:39 PM.
Reply With Quote
  #8  
Old 01-27-2012, 05:15 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 930
The behavior your describing with the whole line being deleted matches what one might expect when pressing Ctrl+U (or whatever your term cap has defined for the "kill" functionality).

With respect to this behavior being specific to 'screen', it would appear that perhaps your profile/system has a "creative" termcap definition for the screen terminal type.

For example, once you start screen, what is the "kill" setting as reported by 'stty -a'?

Feel free to provide all 'stty -a' output when you're in 'screen', as there might be other helpful info it contains.

One thing I noticed from your earlier output of 'stty -a' was that your "erase" setting is defined as ^? (delete). This is no problem for shells like bash, which can handle the differences and do the right thing regardless, but since your remote terminal is expecting a delete character for "erase" (backspace), you might consider enabling the "Backspace sends delete" option in SecureCRT's session options Terminal / Emulation / Mapped keys category and see if you get any different behavior.

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 12:18 AM.