A pseudo-terminal is a special interprocess communication channel that acts like a terminal. Sometimes when we run ssh to remote server to execute commands which come from pipe or Here document we may get warning like

Pseudo-terminal will not be allocated because stdin is not a terminal.

The warning message is due to the fact that no command is specified for ssh while stdin is redirected from a here document or pip. Due to the lack of a specified command as an argument ssh first expects an interactive login session (which would require the allocation of a tty on the remote host) but then has to realize that its local stdin is no tty/pty. Redirecting ssh’s stdin from a here document normally requires a command (such as /bin/sh) to be specified as an argument to ssh - and in such a case no pty will be allocated on the remote host by default.

Method 1: use ssh -T option to suppress this warning

j@ubuntu:~/tmp/1030$ ssh -T 192.168.171.161 <<EOF
uptime
date
EOF
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.11.0-37-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage


301 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable

Your Hardware Enablement Stack (HWE) is supported until April 2025.
*** System restart required ***
 01:32:23 up 23:05,  1 user,  load average: 0.00, 0.00, 0.00
Sun 31 Oct 2021 01:32:23 AM PDT
j@ubuntu:~/tmp/1030$

where -T means:

-T      Disable pseudo-terminal allocation.

Because we just want to run some command then exit , so no pseudo-terminal is required , that’s why wo can use this option to suppress the warning message.

And if you need a tty/pseudo-terminal , you can add option -tt to force pseudo-terminal allocation

     -t      Force pseudo-terminal allocation.  This can be used to execute
             arbitrary screen-based programs on a remote machine, which can be
             very useful, e.g. when implementing menu services.  Multiple -t
             options force tty allocation, even if ssh has no local tty.

Method 2: add bash command to suppress the warning

j@ubuntu:~/tmp/1030$ ssh 192.168.171.161 bash <<EOF
> uptime
> hostname
> EOF
 01:44:26 up 23:17,  1 user,  load average: 0.12, 0.10, 0.04
ubuntu1029

Here we can see banner was also been suppressed .

Maybe you want ssh to get stdin from pipe , see below example:

j@ubuntu:~/tmp/1030$ cat 1.sh 
uptime
hostname
j@ubuntu:~/tmp/1030$ cat 1.sh | ssh 192.168.171.161 bash
 01:51:45 up 23:24,  1 user,  load average: 0.07, 0.05, 0.01
ubuntu1029

Without the bash command , we will also get the warning and banner messages.

Method 3: use ssh option -q

Since the warning message is raised by ssh command , we can use option -q to suppress all ssh warnings

j@ubuntu:~/tmp/1030$ cat 1.sh | ssh -q 192.168.171.161
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.11.0-37-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage


301 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable

Your Hardware Enablement Stack (HWE) is supported until April 2025.
*** System restart required ***
 03:25:23 up 1 day, 58 min,  1 user,  load average: 0.17, 0.07, 0.02
ubuntu1029

Where option -q means:

-q      Quiet mode.  Causes most warning and diagnostic messages to be suppressed.

Method 4: use ssh one line command

j@ubuntu:~/tmp/1030$ ssh 192.168.171.161 "uptime;hostname"
 01:53:28 up 23:26,  1 user,  load average: 0.09, 0.05, 0.01
ubuntu1029

See Ssh run multiple commands in one line for more examples.