'Ctrl-j is always changed to Ctrl-m in session started by aws session manager

I used to use ssh to connect remote sever, but recently I started trying AWS session manager. Previously after remote server is connected, I would use tmux for my daily work, and with tmux I prefer Ctrl-j as prefix, this works just fine with ssh connection, but ever since I started with AWS session manager, I found Ctrl-j binding does not work as expected, then I found below key stroke printing.

  • with ssh connection started by ssh <hostname>
$ showkey -a

Press any keys - Ctrl-D will terminate this program

^J   10 0012 0x0a
^M   13 0015 0x0d
  • with AWS session manager session started by aws ssm start-session --target <instance_id>
$ showkey -a

Press any keys - Ctrl-D will terminate this program

^M   13 0015 0x0d      # I actually stroke Ctrl-j here
^M   13 0015 0x0d

Both connections were made from the same terminal window, so I guess there should be nothing to do with my terminal configuration, does anyone happen to know what's going on? And how could I manage to use Ctrl-j as tmux prefix in AWS session?

BTW, if it will help, here are the stty settings both locally and on remote server

###### Locally
$ stty -a
speed 38400 baud; 54 rows; 213 columns;
lflags: icanon isig iexten echo echoe echok echoke -echonl echoctl
    -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
    -extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8
    -ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
    -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = <undef>; eof = ^D; eol = <undef>;
    eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
    min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
    stop = ^S; susp = ^Z; time = 0; werase = ^W;


#### ssh connection server
$ stty -a
speed 38400 baud; rows 54; columns 213; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar 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


#### AWS session connection server
$ stty -a
speed 38400 baud; rows 54; columns 213; 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 -cmspar 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


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source