Monday, 30 October 2023

bash,git bash error - Pseudo-terminal will not be allocated because stdin is not a terminal

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

is an error when you do ssh to a remote server and you dont have any terminal:

https://www.baeldung.com/linux/ssh-pseudo-terminal-allocation#:~:text=In%20this%20case%2C%20ssh%20doesn,ssh%20prints%20this%20error%20message.


A pseudo-terminal, pseudo-TTY, or simply pty is a device that emulates a physical terminal. It allows programs to interact with users as if they’re running on a real terminal, even if they’re not.


When we use ssh to connect to a remote machine, ssh allocates a pty on the remote machine and connects it to our local terminal. However, sometimes we may want to run a command on the remote machine without a terminal. For example, we may want to redirect the standard input (stdin) of the command from a file or another command.


In this case, ssh doesn’t allocate a pty on the remote machine, because stdin isn’t a terminal. This causes problems if the command we’re trying to run expects to be run in a terminal. The command may fail or behave unexpectedly, and ssh prints this error message.


solution:

https://stackoverflow.com/questions/7114990/pseudo-terminal-will-not-be-allocated-because-stdin-is-not-a-terminal

ssh -tt

-T      Disable pseudo-tty allocation.

-t      Force pseudo-tty 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.

": If you provide commands to ssh via stdin, its stdin, due to the input redirection, is no longer connected to a terminal, so in that sense "ssh has no local tty" anymore. It is in this scenario that a single -t is insufficient to allocate a pty and -t -t (-tt) must be used instead."



No comments:

Post a Comment