gdbserver
doesn't read from stdin, so the program it invokes will have unfettered access to stdin. You should be able to do this:
ssh -T remote_host "cd ~/mydir && gdbserver :1234 ~/myprogram" < input.txt
where 1234
is an unused port. Then,
(gdb) target remote remote_host:1234
A drawback with this is that the gdb-gdbserver
TCP connection won't be encrypted.