I installed ubuntu server on a virtual machine (virtual box), and set up ssh. I made sure that everything worked and I disabled all firewalls, but when I try to connect via ssh from Microsoft's windows it says “connection timed out”. I thought maybe the server is not accessible, so when I tried to ping the server, it also said timed out. Does anyone know how to resolve this?
NAT mode in virtualbox typically doesn't support initiating connections to the guest machine (or at least not easily). You may want to switch it into bridged mode.
When the guest OS boots, it typically uses DHCP to get an IP address. VirtualBox will field this DHCP request and tell the guest OS its assigned IP address and the gateway address for routing outbound connections. In this mode, every vm is assigned the same IP address (10.0.2.15) because each vm thinks they are on their own isolated network. And when they send their traffic via the gateway (10.0.2.2) VirtualBox rewrites the packets to make them appear as though they originated from the Host, rather than the Guest (running inside the Host).
This means that the Guest will work even as the Host moves from network to network (e.g. laptop moving between locations), and from wireless to wired connections too.
However, how does another computer initiate a connection into a Guest? e.g. connecting to a web server running in the Guest. This is not (normally) possible using NAT mode as there is no route into the Guest OS. So for vm's running servers we need a different networking mode....
Bridged Networking is used when you want your vm to be a full network citizen, i.e. to be an equal to your host machine on the network; in this mode, a virtual NIC is "bridged" to a physical NIC on your host.
The effect of this is that each VM has access to the physical network in the same way as your host. It can access any service on the network such as external DHCP services, name lookup services, and routing information just as the host does.
More information: Oracle VM VirtualBox: Networking options and how-to manage them
As ctrl-alt-delor suggests a "Host-only" network may also work for you. This would allow your host machine and virtual machine(s) to be able to communicate between each other but will not allow machines outside your host machine to be able to communicate into your VMs.