code: func (ns *NodeSession) allocateTerminal(termType string, s *ssh.Session) (io.ReadWriteCloser, error) {
  	var err error
  	// read the size of the terminal window:
  	tsize := &term.Winsize{
  		Width:  teleport.DefaultTerminalWidth,
  		Height: teleport.DefaultTerminalHeight,
  	}
  	if ns.isTerminalAttached() {
  		tsize, err = term.GetWinsize(0)
  		if err != nil {
  			log.Error(err)
  		}
  	}
  	// ... and request a server-side terminal of the same size:
  	err = s.RequestPty(termType,
  		int(tsize.Height),
  		int(tsize.Width),
  		ssh.TerminalModes{})
  	if err != nil {
  		return nil, trace.Wrap(err)
  	}
  	writer, err := s.StdinPipe()
  	if err != nil {
  		return nil, trace.Wrap(err)
  	}
  	reader, err := s.StdoutPipe()
  	if err != nil {
  		return nil, trace.Wrap(err)
  	}
  	stderr, err := s.StderrPipe()
  	if err != nil {
  		return nil, trace.Wrap(err)
  	}
  	if ns.isTerminalAttached() {
  		go ns.updateTerminalSize(s)
  	}
  	go func() {
  		io.Copy(os.Stderr, stderr)
  	}()
  	return utils.NewPipeNetConn(
  		reader,
  		writer,
  		utils.MultiCloser(writer, s, ns.closer),
  		&net.IPAddr{},
  		&net.IPAddr{},
  	), nil
  }
docs: // allocateTerminal creates (allocates) a server-side terminal for this session.