By default all servers are firewall enabled.
Which mean you have to add ports inside the firewall to get access.
I this case once you create new VM for the first time, you have to add port 22 inside the firewall,
In case you later changed your SSH port, then again you have to add the new custom port inside the firewall to make it work
Kindly please follow our documentation on how to add port inside the firewall
Link: How to add port inside firewall