If it isn’t already installed, install OpenSSH using the following code in Terminal:
sudo apt install openssh-server
Check that OpenSSH is running correctly using:
sudo service ssh status
The SSH port used can be edited by editing the configuration file in nano using the following code:
sudo nano /etc/ssh/sshd_config
To change the port, edit the line Port 22 to whichever port is preferred. Apply the changes using the following code in Terminal:
sudo service ssh restart
You should now be able to log in using SSH from another machine. Replacing PORT with the correct port number, USERNAME with the correct username, and HOSTNAME with the correct hostname, use the following code:
ssh -p PORT USERNAME@HOSTNAME
Source:
http://ubuntuhandbook.org/index.php/2016/04/enable-ssh-ubuntu-16-04-lts/