In earlier Ubuntu versions I would do:
sudo apt-get install numlockx
sudo sed -i 's|^exit 0.*$|# Numlock enable\n[ -x /usr/bin/numlockx ] \&\& numlockx on\n\nexit 0|' /etc/rc.local
But starting from version 16.10 there is no file rc.local, so how to I enable numlock in version 17.04 without desktop environment?
Update: I created rc.local file as described https://askubuntu.com/a/919598/158442, then executed commands mentioned earlier and now numpad works when I connect over SSH. For it to work in VirtualBox I added these lines to rc.local:
# Turn Numlock on for the TTYs:
for tty in /dev/tty[1-6]; do
/usr/bin/setleds -D +num < $tty
done
And now everything works!