This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation.
From the Ubuntu virtual machine open the Terminal:
First you will need to install the SSH:
sudo apt-get install openssh-server
Will change the connection port:
sudo gedit /etc/ssh/sshd_config
Now save the file.
Under #What ports, IPs and protocols we listen for
Since I configure this already I am providing the screenshot of the sshd_config file by using the grep command -A1 tells grep to include 1 line after the match. -B1 includes lines before the match.
****I am using this port as an example.*****
In order for changes to take, you have to restart the ssh service.
sudo restart ssh
Check to see if the firewall is installed
dpkg --get-selections ufw
If it is then your output would look like this:
If it is not installed perform this action:
sudo apt-get install ufw
Now enable the ufw:
sudo ufw enable
Next we are going to allow the workstation access to 56628 port from the IP address.
Press the windows key + r and type cmd and press Enter. This will bring up the command prompt. Now type ipconfig /all and locate the IP address of the workstation.
On the Ubuntu virtual machine from the Terminal type:
sudo ufw allow from <The IP address you just located on the windows workstation> to any port 56628