The normal way to connect to an SSH server is ssh username@ip_address
. But a user may only want to run a program on the remote machine. So the program name follows after the normal argument which is ssh username@ip_address <program_name>
. For example, ssh username@ip_address ls
. That argument is fine except for interactive programs (that also accept user input as well as providing output) e.g. top
. The output is
TERM environment variable not set.
which means no (pseudo-)terminal is attached between the sshd and top programs. The solution is to add argument -t
where the whole command now becomes ssh -t username@ip_address top
.
My question is why can't sshd by default also use a pseudo-terminal to communicate with non-interactive programs so there is no need to add the -t
argument for interactive programs?
RequestTTY yes
(orforce
) in your config.top
can run in batch mode.