Pseudo-Terminal Will Not Be Allocated Because Stdin Is Not a Terminal

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

Try ssh -t -t(or ssh -tt for short) to force pseudo-tty allocation even if stdin isn't a terminal.

See also: Terminating SSH session executed by bash script

From ssh manpage:

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

Pseudo-terminal will not allocated because stdin is not a terminal & mess: ttyname failed: Inappropriate ioctl for device

u can write like this:

ssh -tt root@some.ip.address << ENDSSH
your code
exit
ENDSSH

u try it.

How to fix Pseudo-terminal will not be allocated because stdin is not a terminal in Alpine Linux?

I guessed in my question that this would work in an Ubuntu container, and that proved to be correct. Interestingly I still get the "must be run from a terminal" error with this command:

su -c whoami

But not here, where a terminal is allocated explicitly in an SSH passwordless command to self:

ssh -t localhost 'su -c whoami'

Unfortunately the new OS has bumped up my 68M image to 430M, urgh! I should therefore be most happy to receive new answers that get this working on Alpine.

SSH while-loop in bash. Pseudo-terminal will not be allocated because stdin is not a terminal

You aren't running find on the remote host; you are trying to run a login shell on the remote host, and only after that exits would find run. Further, the remote shell fails because its standard input was redirected from /dev/null due to the -n option.

sshCmd="ssh -n -o ConnectTimeout=5 -o Batchmode=yes -o StrictHostKeyChecking=no -o CheckHostIP=no -o PasswordAuthentication=no -q"

while IFS=: read -r f1 f2 f3 f4 ; do
# Beware of values for f2, f3, and f4 containing double quotes themselves.
$sshCmd "$f1" "find \"$f2\" -type f -name \"$f4\" -mtime +\"$f3\""
done

Unrelated, but sshCmd should be a function, not a variable to expand.

sshCmd () {
ssh -n -o ConnectTimeout=5 -o Batchmode=yes -o StrictHostKeyChecking=no -o CheckHostIP=no -q "$@"
}

while IFS=: read -r f1 f2 f3 f4; do
sshCmd "$f1" "find \"$f2\" -type f -name \"$f4\" -mtime +\"$f3\""
done


Related Topics



Leave a reply



Submit