Run htop over ssh via single command

I want to run htop over ssh - but launch it automatically on a keyboard-less system with a shell script. My first idea was

ssh [email protected] 'htop'

but:

Error opening terminal: unknown.

Is there any way to start htop remote without typing the command every connection?

Thanks in advance!


Solution 1:

Use the -t flag with SSH:

ssh [email protected] -t 'htop'

This will force a TTY allocation (ssh doesn't allocate a TTY if it's not necessary, normally only for interactive shells).