I've read here that ssh is considered a pty. Why? If I run an ssh command in my console (say, in a Debian server), where comes the "pty" aspect of ssh here? For me, it's like I'm using any other utility like cat or sed, so where comes the "pty" aspect here?

In screen or tmux it would seem more plausible to use this term (even though I think it's quite uncommon and these should be named "multiplexers").

  • 2
    You heard wrong. ssh is not a pseudoterminal. To learn what a pseudoterminal (pty) is you may begin by reading the manual page of pty - pseudoterminal interfaces. What sshd (the server side of ssh) does is create a pty and run a shell in it. – AlexP Nov 25 '17 at 14:08
  • Actually, the master side and the slave side of a pty must be be on the same machine. When you use ssh interactively, you have the following situation. On the local machine your are running a terminal emulator, such as PuTTY or Xterm. The terminal emulator has the master side of a pty, with the slave side connected to the ssh process. The ssh process talks over the network with the sshd daemon on the remote machine. On the remote machine, the sshd daemon has the master side of a pty, with the slave side connected to the shell or whatever program you are running. – AlexP Nov 25 '17 at 14:17
  • Thank you so much AlexP. This is a great, super clear and didactic explanation for me. I really appreciate your help. I wouldn't allow myself using it into an answer because I think you should just copy it into an answer of yours (with a minor edit) and I will gladly thumb up. – Arcticooling Nov 25 '17 at 14:29

ssh is the client and communicates with your tty via your tty's standard output on the local machine. On the remote machine, a pty is created by sshd when you login.

sshd then executes your shell, connecting it to its pty so that instead of showing up on the remote machine information is forwarded through ssh to the local machine.

The shell connects to the pty just like it would a tty used locally but the information sent to the pty is not printed to the local screen but is directed to sshd then sends it to the connected ssh client which makes sshd a pseudo-terminal.

  • Dear jdwolf. I understood all of the answer besides this The shell connects just like any other tty. Will you please rephrase it or give a small explanation to this sentence? In great plea. – Arcticooling Nov 25 '17 at 14:07
  • @Arcticooling How's that? – jdwolf Nov 25 '17 at 15:06
  • You meant just like it would be? If so it is more understandable. – Arcticooling Nov 25 '17 at 16:01
  • @Arcticooling yes – jdwolf Nov 25 '17 at 16:03

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.