How do I configure a new Ubuntu installation to accept ssh connections?

I just installed Ubuntu. How do I set it up to allow me to ssh into it? Right now I get “ssh: connect to host x.x.x.x port 22: Operation timed out”.

sudo apt-get update
sudo apt-get install openssh-server
sudo ufw allow 22

Source: How do I configure a new Ubuntu installation to accept ssh connections? – Ask Ubuntu