I am confused about what ssh -t does and why I will sometimes need the -t option. My understanding is that if I run ssh -t program, ssh is forced to allocate a pseudo tty, with which it passes the keyboard input to program's and passes the program's output to stdout.
But it seems I am wrong. For example, the following two seem to function identically as I can operate interactively with rclone using either one, even though the first command forces it to allocate a pseudo tty and the second command forces it not to allocate a pseudo tty:
ssh -t user@my.server.com rclone configssh -T user@my.server.com rclone config
So what does ssh -t actually do?
Update:
To illuminate this question further, I made the following python script called hello.py.
import sys, signal
def signal_handler(sig, frame):
print('You pressed Ctrl+C!')
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
print(f"stdin is tty:{sys.stdin.isatty()}")
print(f"stdout is tty:{sys.stdout.isatty()}")
s = input("Enter what you want:")
print("Hello ", s)
On a remote machine, if I invoke it as ssh -t user@server.com "python hello.py", I get the following output:
stdin is tty: true
stdout is tty: true
Enter what you want: cat
Hello cat
If I invoke it as ssh -T user@server.com "python hello.py", I get the following:
stdin is tty: false
stdout is tty: false
Enter what you want: cat
Hello cat
In either case, I am able to interact with the program by typing in "cat" from the keyboard.
One difference I observe is that when I press CTRL-C, the -t version captures SIGINT but the -T version does not.
I'm curious why I can still interact with it even if stdin/stdout is not a tty. Also, isatty() is in fact a standard C library function. What does a (pseudo) TTY really mean here?