Ctrl-Z on an SSH session

10

2

When I SSH into another system and press Ctrl-Z, I expected the SSH client to go into background. However, it's the remote process that does that. Where does the magic happen?

Holy Sheet

Posted 2012-09-27T21:50:22.197

Reputation: 481

Answers

15

The SSH client disables special key handling (stty -icanon -isig options) for the local tty, so when you press CtrlZ, the client just reads the raw byte 0x1A and forwards it to the server.

OpenSSH supports a special command to suspend the client – Enter, then ~, followed by CtrlZ.

user1686

Posted 2012-09-27T21:50:22.197

Reputation: 283 655

I expected the local ssh client to be suspended, not the process on the remote machine. Is there a reason why the ordinary Ctrl-Z is modified instead of a new ~ Ctrl-Z being added for stopping the remote process? – humanityANDpeace – 2019-10-02T11:10:33.850

3At begining of line type ~? to get a full list of escape codes. You can change the escape character using -e when you start ssh. (this applies to openssh, used on most Gnu systems.) – ctrl-alt-delor – 2012-09-27T22:31:15.183