3

I am trying to figure out exactly what is sent to an SSH host when I press CTL-C in either putty or open ssh. All I am trying to do is send control codes pragmatically that are equivalent to when a user presses CTL-Z for example. So far every time I send ^C or \cc or \003 it just prints it out. There must be some sort of additional information to let the terminal know it was ^C escaped?

Any help is appreciated. Thank you

Edit: I am pragmatically sending characters to an SSH session that is already connected to an SSH host. I want to see the same effect as when I have openssh client open and I press CTL-C on my keyboard.

  • To clarify, are you wanting to send something like CTRL-Z to an ssh session programmatically, ie from a script? – 111--- Oct 18 at 20:57
  • Ctrl/C and Ctrl/Z in this context are signals, not characters. You need to explain what you're trying to achieve rather than how to implement what you think needs to be done. – roaima Oct 18 at 21:17
  • I am trying to send characters pragmatically to ssh clients that have an ssh session open to a host. – noone392 Oct 19 at 21:04
  • It all depends on how specifically you want to send control-C to the SSH client, and what exactly that SSH client is. The question as asked, "what is sent to an SSH host when I press CTL-C in PuTTY" is simple: the character control-C, '\x03'. OpenSSH is a suite of utilities and libraries, not an SSH client, so it's meaningless to ask what happens when you "press CTL-C in OpenSSH". – AlexP Oct 20 at 3:04
0

Something like this:

(echo ping google.com; sleep 3; printf "\003"; ) |
  ssh -tt localhost

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.