How to find out the currently active linux virtual terminal while connected via ssh?

fgconsole is what you are looking for

http://linux.die.net/man/1/fgconsole


Alternatively, if you do not want to use sudo to figure out what the current tty is, you can use Linux-specific sysfs entry:

$ cat /sys/class/tty/tty0/active
tty8