code: func (ns *NodeSession) interactiveSession(callback interactiveCallback) error {
  	// determine what kind of a terminal we need
  	termType := os.Getenv("TERM")
  	if termType == "" {
  		termType = teleport.SafeTerminalType
  	}
  	// create the server-side session:
  	sess, err := ns.createServerSession()
  	if err != nil {
  		return trace.Wrap(err)
  	}
  	// allocate terminal on the server:
  	remoteTerm, err := ns.allocateTerminal(termType, sess)
  	if err != nil {
  		return trace.Wrap(err)
  	}
  	defer remoteTerm.Close()
  
  	// call the passed callback and give them the established
  	// ssh session:
  	if err := callback(sess, remoteTerm); err != nil {
  		return trace.Wrap(err)
  	}
  
  	// Catch term signals, but only if we're attached to a real terminal
  	if ns.isTerminalAttached() {
  		ns.watchSignals(remoteTerm)
  	}
  
  	// start piping input into the remote shell and pipe the output from
  	// the remote shell into stdout:
  	ns.pipeInOut(remoteTerm)
  
  	// switch the terminal to raw mode (and switch back on exit!)
  	if ns.isTerminalAttached() {
  		ts, err := term.SetRawTerminal(0)
  		if err != nil {
  			log.Warn(err)
  		} else {
  			defer term.RestoreTerminal(0, ts)
  		}
  	}
  	// wait for the session to end
  	<-ns.closer.C
  	return nil
  }
docs: // interactiveSession creates an interactive session on the remote node, executes
  // the given callback on it, and waits for the session to end