WindowsでTera Termなどのターミナルソフトでssh接続していると、思わずCtrl+S(Stop)を押して
キー入力を受け付けないロック状態にしてしまうことがあります。
Ctrl+Qを押せば解除されるのですが、本資料はCtrl+S自体を無効にする方法を記します。
ついつい慣れていないと押してしまうCtrl+Sという状態であれば、.bashrcに以下の構文を追記します。
動作確認はCentOS6で行いました。
stty stop undef
catコマンドで出力した.bashrcの内容です。
一番最後に追記しています。(ただし問題があります。問題と解決策も以下に記述してあります。)
[sakura@centos6 ~]$ cat .bashrc # .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # User specific aliases and functions stty stop undef
これにより、Ctrl+Sで端末がロックすることはなくなります。
bashを使用しているので、Ctrl+Sを押すとi-searchと表示されるようになります。
しかし困ったことにscpコマンドでファイルを設定したマシンに対してコピーすると以下のようなエラーが発生してしまいます。
この問題に対する対処方法は、以下に記します。
[sakura@centos6 ~]$ scp file localhost: sakura@localhost's password: stty: 標準入力: 無効な引数です file 100% 2 0.0KB/s 00:00
scpのエラー回避策は、接続後に端末でstty stop undefを入力し設定するか、以下のように.bashrcを設定します。
参考記事 : scpができなくなった時の対処法・bashrc編
上記では最後に以下の1行を追記しました。
stty stop undef
これを以下のように変更します。
if [ "$SSH_TTY" != "" ]; then stty stop undef fi
catコマンドで出力した.bashrcの内容です。
[sakura@centos6 ~]$ cat .bashrc # .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # User specific aliases and functions if [ "$SSH_TTY" != "" ]; then stty stop undef fi
sttyコマンドでキーに割り当てられている動作を確認してみます。
以下、stty -a で出力した結果です。
[sakura@centos6 ~]$ stty -a speed 9600 baud; rows 24; columns 80; line = 0; intr = ^C; quit = ^\; erase = ^H; 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
上記の出力をみると、以下の記述が表示されています。
^はCtrlになります。
start = ^Q; stop = ^S
つまり、Ctrl+Sはstop, Ctrl+Qはstartになります。
以上、Ctrl+Sによる端末ロックを無効にする方法でした。