ssh backspace not working until I manually run TERM=xterm












4















I understand that backspace might now work in an ssh session if TERM is set incorrectly. But strangely, I have a server where TERM is set correctly, but backspace does not work until I manually set TERM=xterm in the shell (which should be redundant). See here:



~ ] ssh root@192.168.10.40
root 192.168.10.40 / # echo $0
-bash
root 192.168.10.40 / # echo $TERM
xterm-256color
root 192.168.10.40 / # # backspace does not work :(
root 192.168.10.40 / #
root 192.168.10.40 / # TERM=xterm-256color
root 192.168.10.40 / # # now backspace works!!
root 192.168.10.40 / # logout


I would say about 90% of the time, backspace does not work until I run TERM=xterm, and 10% of the time, I don't need to run the TERM= command because backspace is already working. I've compared the output of env for each case, and they are identical (aside from SSH_CLIENT and SSH_CONNECTION where only the client side port has changed)



Any idea what may cause this behavior, or what a workaround might be?





Response to comments



I am using OpenSSH_6.8p1, BoringSSL from https://android.googlesource.com/platform/external/openssh, and I am running GNU bash, version 4.3.42(1)-release (arm-android-eabi) from https://github.com/CyanogenMod/android_external_bash.git



stty -a shows no different before and after setting XTERM. Output is:



speed 38400 baud; rows 102; columns 319; line = 2;
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
-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


bind -p|egrep 'delete|rubout|kill' also shows no different before and after setting XTERM. Output is:



"C-h": backward-delete-char
"C-?": backward-delete-char
"C-xC-?": backward-kill-line
"eC-h": backward-kill-word
"eC-?": backward-kill-word
# copy-region-as-kill (not bound)
"C-d": delete-char
"e[3~": delete-char
# delete-char-or-list (not bound)
"e\": delete-horizontal-space
# forward-backward-delete-char (not bound)
"C-k": kill-line
# kill-region (not bound)
# kill-whole-line (not bound)
"ed": kill-word
# shell-backward-kill-word (not bound)
# shell-kill-word (not bound)
# unix-filename-rubout (not bound)
"C-w": unix-word-rubout
# vi-delete (not bound)
# vi-delete-to (not bound)
# vi-overstrike-delete (not bound)
# vi-rubout (not bound)


Interestingly, if I source my bashrc, my backspace starts working again. I know the bashrc is being sourced on login though because that is the only place where I set my Ps1 value










share|improve this question

























  • what's the server? SSH server name and version?

    – Jakuje
    Sep 29 '16 at 19:34











  • your shell may run a script to update the prompt, and in that script the TERM value might be used to update the terminal settings.

    – Thomas Dickey
    Sep 29 '16 at 20:42











  • Could you do "stty -a" before and after the assignment, and see if there is any difference? Just a try to debug.

    – Göran Uddeborg
    Sep 29 '16 at 21:08











  • One other thing that will help people: The outputs of bind -p|egrep 'delete|rubout|kill' run before and afterwards.

    – JdeBP
    Sep 30 '16 at 9:43











  • An application could be initializing the terminal, sending 33[?67h (or 033[?67l) aka DECBKM. If you check what is actually sent (use cat -v to make the key readable, using ^V to help), does that change?

    – Thomas Dickey
    Sep 30 '16 at 17:48
















4















I understand that backspace might now work in an ssh session if TERM is set incorrectly. But strangely, I have a server where TERM is set correctly, but backspace does not work until I manually set TERM=xterm in the shell (which should be redundant). See here:



~ ] ssh root@192.168.10.40
root 192.168.10.40 / # echo $0
-bash
root 192.168.10.40 / # echo $TERM
xterm-256color
root 192.168.10.40 / # # backspace does not work :(
root 192.168.10.40 / #
root 192.168.10.40 / # TERM=xterm-256color
root 192.168.10.40 / # # now backspace works!!
root 192.168.10.40 / # logout


I would say about 90% of the time, backspace does not work until I run TERM=xterm, and 10% of the time, I don't need to run the TERM= command because backspace is already working. I've compared the output of env for each case, and they are identical (aside from SSH_CLIENT and SSH_CONNECTION where only the client side port has changed)



Any idea what may cause this behavior, or what a workaround might be?





Response to comments



I am using OpenSSH_6.8p1, BoringSSL from https://android.googlesource.com/platform/external/openssh, and I am running GNU bash, version 4.3.42(1)-release (arm-android-eabi) from https://github.com/CyanogenMod/android_external_bash.git



stty -a shows no different before and after setting XTERM. Output is:



speed 38400 baud; rows 102; columns 319; line = 2;
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
-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


bind -p|egrep 'delete|rubout|kill' also shows no different before and after setting XTERM. Output is:



"C-h": backward-delete-char
"C-?": backward-delete-char
"C-xC-?": backward-kill-line
"eC-h": backward-kill-word
"eC-?": backward-kill-word
# copy-region-as-kill (not bound)
"C-d": delete-char
"e[3~": delete-char
# delete-char-or-list (not bound)
"e\": delete-horizontal-space
# forward-backward-delete-char (not bound)
"C-k": kill-line
# kill-region (not bound)
# kill-whole-line (not bound)
"ed": kill-word
# shell-backward-kill-word (not bound)
# shell-kill-word (not bound)
# unix-filename-rubout (not bound)
"C-w": unix-word-rubout
# vi-delete (not bound)
# vi-delete-to (not bound)
# vi-overstrike-delete (not bound)
# vi-rubout (not bound)


Interestingly, if I source my bashrc, my backspace starts working again. I know the bashrc is being sourced on login though because that is the only place where I set my Ps1 value










share|improve this question

























  • what's the server? SSH server name and version?

    – Jakuje
    Sep 29 '16 at 19:34











  • your shell may run a script to update the prompt, and in that script the TERM value might be used to update the terminal settings.

    – Thomas Dickey
    Sep 29 '16 at 20:42











  • Could you do "stty -a" before and after the assignment, and see if there is any difference? Just a try to debug.

    – Göran Uddeborg
    Sep 29 '16 at 21:08











  • One other thing that will help people: The outputs of bind -p|egrep 'delete|rubout|kill' run before and afterwards.

    – JdeBP
    Sep 30 '16 at 9:43











  • An application could be initializing the terminal, sending 33[?67h (or 033[?67l) aka DECBKM. If you check what is actually sent (use cat -v to make the key readable, using ^V to help), does that change?

    – Thomas Dickey
    Sep 30 '16 at 17:48














4












4








4








I understand that backspace might now work in an ssh session if TERM is set incorrectly. But strangely, I have a server where TERM is set correctly, but backspace does not work until I manually set TERM=xterm in the shell (which should be redundant). See here:



~ ] ssh root@192.168.10.40
root 192.168.10.40 / # echo $0
-bash
root 192.168.10.40 / # echo $TERM
xterm-256color
root 192.168.10.40 / # # backspace does not work :(
root 192.168.10.40 / #
root 192.168.10.40 / # TERM=xterm-256color
root 192.168.10.40 / # # now backspace works!!
root 192.168.10.40 / # logout


I would say about 90% of the time, backspace does not work until I run TERM=xterm, and 10% of the time, I don't need to run the TERM= command because backspace is already working. I've compared the output of env for each case, and they are identical (aside from SSH_CLIENT and SSH_CONNECTION where only the client side port has changed)



Any idea what may cause this behavior, or what a workaround might be?





Response to comments



I am using OpenSSH_6.8p1, BoringSSL from https://android.googlesource.com/platform/external/openssh, and I am running GNU bash, version 4.3.42(1)-release (arm-android-eabi) from https://github.com/CyanogenMod/android_external_bash.git



stty -a shows no different before and after setting XTERM. Output is:



speed 38400 baud; rows 102; columns 319; line = 2;
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
-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


bind -p|egrep 'delete|rubout|kill' also shows no different before and after setting XTERM. Output is:



"C-h": backward-delete-char
"C-?": backward-delete-char
"C-xC-?": backward-kill-line
"eC-h": backward-kill-word
"eC-?": backward-kill-word
# copy-region-as-kill (not bound)
"C-d": delete-char
"e[3~": delete-char
# delete-char-or-list (not bound)
"e\": delete-horizontal-space
# forward-backward-delete-char (not bound)
"C-k": kill-line
# kill-region (not bound)
# kill-whole-line (not bound)
"ed": kill-word
# shell-backward-kill-word (not bound)
# shell-kill-word (not bound)
# unix-filename-rubout (not bound)
"C-w": unix-word-rubout
# vi-delete (not bound)
# vi-delete-to (not bound)
# vi-overstrike-delete (not bound)
# vi-rubout (not bound)


Interestingly, if I source my bashrc, my backspace starts working again. I know the bashrc is being sourced on login though because that is the only place where I set my Ps1 value










share|improve this question
















I understand that backspace might now work in an ssh session if TERM is set incorrectly. But strangely, I have a server where TERM is set correctly, but backspace does not work until I manually set TERM=xterm in the shell (which should be redundant). See here:



~ ] ssh root@192.168.10.40
root 192.168.10.40 / # echo $0
-bash
root 192.168.10.40 / # echo $TERM
xterm-256color
root 192.168.10.40 / # # backspace does not work :(
root 192.168.10.40 / #
root 192.168.10.40 / # TERM=xterm-256color
root 192.168.10.40 / # # now backspace works!!
root 192.168.10.40 / # logout


I would say about 90% of the time, backspace does not work until I run TERM=xterm, and 10% of the time, I don't need to run the TERM= command because backspace is already working. I've compared the output of env for each case, and they are identical (aside from SSH_CLIENT and SSH_CONNECTION where only the client side port has changed)



Any idea what may cause this behavior, or what a workaround might be?





Response to comments



I am using OpenSSH_6.8p1, BoringSSL from https://android.googlesource.com/platform/external/openssh, and I am running GNU bash, version 4.3.42(1)-release (arm-android-eabi) from https://github.com/CyanogenMod/android_external_bash.git



stty -a shows no different before and after setting XTERM. Output is:



speed 38400 baud; rows 102; columns 319; line = 2;
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
-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


bind -p|egrep 'delete|rubout|kill' also shows no different before and after setting XTERM. Output is:



"C-h": backward-delete-char
"C-?": backward-delete-char
"C-xC-?": backward-kill-line
"eC-h": backward-kill-word
"eC-?": backward-kill-word
# copy-region-as-kill (not bound)
"C-d": delete-char
"e[3~": delete-char
# delete-char-or-list (not bound)
"e\": delete-horizontal-space
# forward-backward-delete-char (not bound)
"C-k": kill-line
# kill-region (not bound)
# kill-whole-line (not bound)
"ed": kill-word
# shell-backward-kill-word (not bound)
# shell-kill-word (not bound)
# unix-filename-rubout (not bound)
"C-w": unix-word-rubout
# vi-delete (not bound)
# vi-delete-to (not bound)
# vi-overstrike-delete (not bound)
# vi-rubout (not bound)


Interestingly, if I source my bashrc, my backspace starts working again. I know the bashrc is being sourced on login though because that is the only place where I set my Ps1 value







bash ssh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 13 '17 at 15:36









Tomasz

9,62652965




9,62652965










asked Sep 29 '16 at 18:37









peskalpeskal

24219




24219













  • what's the server? SSH server name and version?

    – Jakuje
    Sep 29 '16 at 19:34











  • your shell may run a script to update the prompt, and in that script the TERM value might be used to update the terminal settings.

    – Thomas Dickey
    Sep 29 '16 at 20:42











  • Could you do "stty -a" before and after the assignment, and see if there is any difference? Just a try to debug.

    – Göran Uddeborg
    Sep 29 '16 at 21:08











  • One other thing that will help people: The outputs of bind -p|egrep 'delete|rubout|kill' run before and afterwards.

    – JdeBP
    Sep 30 '16 at 9:43











  • An application could be initializing the terminal, sending 33[?67h (or 033[?67l) aka DECBKM. If you check what is actually sent (use cat -v to make the key readable, using ^V to help), does that change?

    – Thomas Dickey
    Sep 30 '16 at 17:48



















  • what's the server? SSH server name and version?

    – Jakuje
    Sep 29 '16 at 19:34











  • your shell may run a script to update the prompt, and in that script the TERM value might be used to update the terminal settings.

    – Thomas Dickey
    Sep 29 '16 at 20:42











  • Could you do "stty -a" before and after the assignment, and see if there is any difference? Just a try to debug.

    – Göran Uddeborg
    Sep 29 '16 at 21:08











  • One other thing that will help people: The outputs of bind -p|egrep 'delete|rubout|kill' run before and afterwards.

    – JdeBP
    Sep 30 '16 at 9:43











  • An application could be initializing the terminal, sending 33[?67h (or 033[?67l) aka DECBKM. If you check what is actually sent (use cat -v to make the key readable, using ^V to help), does that change?

    – Thomas Dickey
    Sep 30 '16 at 17:48

















what's the server? SSH server name and version?

– Jakuje
Sep 29 '16 at 19:34





what's the server? SSH server name and version?

– Jakuje
Sep 29 '16 at 19:34













your shell may run a script to update the prompt, and in that script the TERM value might be used to update the terminal settings.

– Thomas Dickey
Sep 29 '16 at 20:42





your shell may run a script to update the prompt, and in that script the TERM value might be used to update the terminal settings.

– Thomas Dickey
Sep 29 '16 at 20:42













Could you do "stty -a" before and after the assignment, and see if there is any difference? Just a try to debug.

– Göran Uddeborg
Sep 29 '16 at 21:08





Could you do "stty -a" before and after the assignment, and see if there is any difference? Just a try to debug.

– Göran Uddeborg
Sep 29 '16 at 21:08













One other thing that will help people: The outputs of bind -p|egrep 'delete|rubout|kill' run before and afterwards.

– JdeBP
Sep 30 '16 at 9:43





One other thing that will help people: The outputs of bind -p|egrep 'delete|rubout|kill' run before and afterwards.

– JdeBP
Sep 30 '16 at 9:43













An application could be initializing the terminal, sending 33[?67h (or 033[?67l) aka DECBKM. If you check what is actually sent (use cat -v to make the key readable, using ^V to help), does that change?

– Thomas Dickey
Sep 30 '16 at 17:48





An application could be initializing the terminal, sending 33[?67h (or 033[?67l) aka DECBKM. If you check what is actually sent (use cat -v to make the key readable, using ^V to help), does that change?

– Thomas Dickey
Sep 30 '16 at 17:48










1 Answer
1






active

oldest

votes


















0














Seems like readline/terminal interaction, start by checking your .inputrc, /etc/inputrc, /etc/default/login, INPUTRC environment variable during the login process, and then readline bindings (via bind -q backward-delete-char).



No harm double checking what's in the client (ssh_config) SendEnv and server (sshd_config AcceptEnv) directives too, if anything (though TERM is not sent from client to server this way in OpenSSH, the client always includes the TERM value in the session setup, and the server set TERM from that). The occasional presence of TERMINFO or TERMCAP in the environment is the only thing I can think of to explain the intermittent nature of this.



Readline applies "rubout" to whatever the terminal declares its "erase" is, and rubout is what readline invokes via backward-delete-char.



TERM is one of the special variables that bash monitors, when it's set (independent of whether it changes) bash resets the terminal:



/* What to do just after one of the TERMxxx variables has changed.
If we are an interactive shell, then try to reset the terminal
information in readline. */
void
sv_terminal (name)
char *name;
{
if (interactive_shell && no_line_editing == 0)
rl_reset_terminal (get_string_value ("TERM"));
}


(where "TERMxxx" means TERM, TERMCAP and TERMINFO) so this explains why simply setting TERM to its current value actually performs an action.



If you cannot track it down, adding "TERM=${TERM}" at the end of your .profile/.bashrc might be a work-around.



As a last resort you could also try some forensic measures, as detailed in my answer here: Monitor and alert user when stty settings change?






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f313255%2fssh-backspace-not-working-until-i-manually-run-term-xterm%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Seems like readline/terminal interaction, start by checking your .inputrc, /etc/inputrc, /etc/default/login, INPUTRC environment variable during the login process, and then readline bindings (via bind -q backward-delete-char).



    No harm double checking what's in the client (ssh_config) SendEnv and server (sshd_config AcceptEnv) directives too, if anything (though TERM is not sent from client to server this way in OpenSSH, the client always includes the TERM value in the session setup, and the server set TERM from that). The occasional presence of TERMINFO or TERMCAP in the environment is the only thing I can think of to explain the intermittent nature of this.



    Readline applies "rubout" to whatever the terminal declares its "erase" is, and rubout is what readline invokes via backward-delete-char.



    TERM is one of the special variables that bash monitors, when it's set (independent of whether it changes) bash resets the terminal:



    /* What to do just after one of the TERMxxx variables has changed.
    If we are an interactive shell, then try to reset the terminal
    information in readline. */
    void
    sv_terminal (name)
    char *name;
    {
    if (interactive_shell && no_line_editing == 0)
    rl_reset_terminal (get_string_value ("TERM"));
    }


    (where "TERMxxx" means TERM, TERMCAP and TERMINFO) so this explains why simply setting TERM to its current value actually performs an action.



    If you cannot track it down, adding "TERM=${TERM}" at the end of your .profile/.bashrc might be a work-around.



    As a last resort you could also try some forensic measures, as detailed in my answer here: Monitor and alert user when stty settings change?






    share|improve this answer




























      0














      Seems like readline/terminal interaction, start by checking your .inputrc, /etc/inputrc, /etc/default/login, INPUTRC environment variable during the login process, and then readline bindings (via bind -q backward-delete-char).



      No harm double checking what's in the client (ssh_config) SendEnv and server (sshd_config AcceptEnv) directives too, if anything (though TERM is not sent from client to server this way in OpenSSH, the client always includes the TERM value in the session setup, and the server set TERM from that). The occasional presence of TERMINFO or TERMCAP in the environment is the only thing I can think of to explain the intermittent nature of this.



      Readline applies "rubout" to whatever the terminal declares its "erase" is, and rubout is what readline invokes via backward-delete-char.



      TERM is one of the special variables that bash monitors, when it's set (independent of whether it changes) bash resets the terminal:



      /* What to do just after one of the TERMxxx variables has changed.
      If we are an interactive shell, then try to reset the terminal
      information in readline. */
      void
      sv_terminal (name)
      char *name;
      {
      if (interactive_shell && no_line_editing == 0)
      rl_reset_terminal (get_string_value ("TERM"));
      }


      (where "TERMxxx" means TERM, TERMCAP and TERMINFO) so this explains why simply setting TERM to its current value actually performs an action.



      If you cannot track it down, adding "TERM=${TERM}" at the end of your .profile/.bashrc might be a work-around.



      As a last resort you could also try some forensic measures, as detailed in my answer here: Monitor and alert user when stty settings change?






      share|improve this answer


























        0












        0








        0







        Seems like readline/terminal interaction, start by checking your .inputrc, /etc/inputrc, /etc/default/login, INPUTRC environment variable during the login process, and then readline bindings (via bind -q backward-delete-char).



        No harm double checking what's in the client (ssh_config) SendEnv and server (sshd_config AcceptEnv) directives too, if anything (though TERM is not sent from client to server this way in OpenSSH, the client always includes the TERM value in the session setup, and the server set TERM from that). The occasional presence of TERMINFO or TERMCAP in the environment is the only thing I can think of to explain the intermittent nature of this.



        Readline applies "rubout" to whatever the terminal declares its "erase" is, and rubout is what readline invokes via backward-delete-char.



        TERM is one of the special variables that bash monitors, when it's set (independent of whether it changes) bash resets the terminal:



        /* What to do just after one of the TERMxxx variables has changed.
        If we are an interactive shell, then try to reset the terminal
        information in readline. */
        void
        sv_terminal (name)
        char *name;
        {
        if (interactive_shell && no_line_editing == 0)
        rl_reset_terminal (get_string_value ("TERM"));
        }


        (where "TERMxxx" means TERM, TERMCAP and TERMINFO) so this explains why simply setting TERM to its current value actually performs an action.



        If you cannot track it down, adding "TERM=${TERM}" at the end of your .profile/.bashrc might be a work-around.



        As a last resort you could also try some forensic measures, as detailed in my answer here: Monitor and alert user when stty settings change?






        share|improve this answer













        Seems like readline/terminal interaction, start by checking your .inputrc, /etc/inputrc, /etc/default/login, INPUTRC environment variable during the login process, and then readline bindings (via bind -q backward-delete-char).



        No harm double checking what's in the client (ssh_config) SendEnv and server (sshd_config AcceptEnv) directives too, if anything (though TERM is not sent from client to server this way in OpenSSH, the client always includes the TERM value in the session setup, and the server set TERM from that). The occasional presence of TERMINFO or TERMCAP in the environment is the only thing I can think of to explain the intermittent nature of this.



        Readline applies "rubout" to whatever the terminal declares its "erase" is, and rubout is what readline invokes via backward-delete-char.



        TERM is one of the special variables that bash monitors, when it's set (independent of whether it changes) bash resets the terminal:



        /* What to do just after one of the TERMxxx variables has changed.
        If we are an interactive shell, then try to reset the terminal
        information in readline. */
        void
        sv_terminal (name)
        char *name;
        {
        if (interactive_shell && no_line_editing == 0)
        rl_reset_terminal (get_string_value ("TERM"));
        }


        (where "TERMxxx" means TERM, TERMCAP and TERMINFO) so this explains why simply setting TERM to its current value actually performs an action.



        If you cannot track it down, adding "TERM=${TERM}" at the end of your .profile/.bashrc might be a work-around.



        As a last resort you could also try some forensic measures, as detailed in my answer here: Monitor and alert user when stty settings change?







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 8 at 12:12









        mr.spuraticmr.spuratic

        6,9811128




        6,9811128






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f313255%2fssh-backspace-not-working-until-i-manually-run-term-xterm%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to make a Squid Proxy server?

            Is this a new Fibonacci Identity?

            19世紀