2

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").

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
  • 3
    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
  • 2
    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

1 Answers1

8

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.

Manuel Jordan
  • 1,728
  • 2
  • 16
  • 40
jdwolf
  • 5,017