When pi is connected to wifi and you are also in same network, if you try to ssh on the IP of Pi it does not work due to security reason we need to enable ssh in Pi.

login to command prompt on Pi by connecting the keyboard and login, change user to root by

su -

give command

root@raspberrypi:~# raspi-config

Select

Interfacing Options

P2 SSH

Select Yes in option “Would you like the SSH server to be enabled? ”

 

Do remember you need to login as pi user on ssh then su to root, it will not allow to login as root on prompt ….