Step 1: Open terminal from Ubuntu dash or by keyboard shortcut CTRL+ATL+T
Step 2: Check if SSH is already installed or not using command
# ssh local host
(If it shows “connect to host localhost port 22: connection refused” you can continue the process)
Step 3: Update the package repository using command
# sudo apt-get update
Step 4: Install OpenSSH software using command
# sudo apt-get install openssh-server
(Password is required to install process since we are using sudo command)
Step5: To verify the installation was successful and to check SHH is running or not, use command
# sudo service ssh status
If “Active: active (running)” is displayed it means SSH is installed and working in work machine.
Log into Remote Server with SSH
Step 1: Open the terminal and type following command
# ssh username@IP – p222
(Replace username and IP with your username and IP)
SSH Configuration to change SSH port number
Step 1: Use Gedit or nano text editor to edit SSH config file using command
# sudo gedit /etc/ssh/sshd_config
Or
# sudo nano /etc/ssh/sshd_config
Step 2: By Default SSH Port number is 22, you can change the port number by replace 22 with desired port number
Step 3: For the changes to take into effect, restart SSH with the following command:
# sudo systemctl restart sshd.service
Configure Firewall
The default firewall configurations tool in Ubuntu is UFW, configure it with the command:
# sudo ufw allow from any to any port xxxx proto tcp
(Replace xxxx with your port number).