If you didn’t open port 22 during the Virtual Machine creation in AWS or Azure and having connection experience timeout issues then you have to open it under your settings. Note that even if you open the port under the Virtual Machine (VM) Inbound Rules does not mean you can connect to the VM without configuring the AWS/Azure network settings.
For example, If you are using Azure then you also need to open the SSH port 22 under “Networking”. This is because the SFTP server uses the underlying SSH tunneling settings.

If you are using AWS Virtual Machine (VM) then it should pretty closely similar as the SSH port settings never change unless you decided to use different configurations.