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
How to Split One Text File into Multiple *.Txt Files
Assembling 32-Bit Binaries on a 64-Bit System (Gnu Toolchain)
How Do the Likely/Unlikely Macros in the Linux Kernel Work and What Is Their Benefit
./Configure: /Bin/Sh^M: Bad Interpreter
What Happens If There Is No Exit System Call in an Assembly Program
Git Asks For Username Every Time I Push
How to Kill a Process by Name Instead of Pid, on Linux
Pipe Only Stderr Through a Filter
How to Change the Default Browser Used by the Ipython/Jupyter Notebook in Linux
Kdevtmpfsi Using the Entire Cpu
Facing an Error "*** Glibc Detected *** Free(): Invalid Next Size (Fast)"
How to Write Standard Error to a File While Using "Tee" With a Pipe
Read Values into a Shell Variable from a Pipe
Simulate Delayed and Dropped Packets on Linux
Shell Command to Tar Directory Excluding Certain Files/Folders