Table of Contents
This tutorial assumes you are on a Linux system and know a little about SSH. SSH allows you to safely log into and manage remote computers. Telnet used to be used but Telnet traffic was not encrypted.
This tutorial assumes that you already created your SSH keys and know how to SSH into a remote server.
Installing OpenSSH.
The command below will install openssh on your system. The standard port or SSH is port 22 but this change be changed.
Check this guide out for creating SSH profiles. This makes it easy to SSH into machines without having to remember the IP of the remote host.
sudo apt install openssh-server -y
A SSH server file has a config file that you can change. They are usually stored in the /etc/ssh/ folder.
sudo nano /etc/ssh/sshd_config
After opening the sshd_config file you should locate a line that starts with a hashtag ( # ) and has the word Port 22. Now all you do is change the number 22 to the port you want and remove the hashtag from the start of that line.
Now that you changed the port that the SSH server listened to you have to make sure the port is accessible outside your network.
If you want it only to be accessible within your network, skip this part.
Allowing The New Port Through The Firewall.
In this tutorial we will be using ufw. We changed the port in the SSH config to port 3333. Now we have to open that port so you can connect to the
sudo ufw enable
sudo ufw allow 3333/tcp
Restarting The SSH Service.
Now that we made changes to the SSH config we must restart the SSH service so that the changes can take affect. The command below can be used to do just that.
sudo service ssh restart
Checking If Port Is Open.
Now we need to make sure that the port 3333 is open on the machine. The Linux command below can be used to check.
sudo ss -tlnp
- -t – Displays the TCP ports
- -l – Only shows open ports
- -n – Does not resolve the service names
- -p – Shows the PID of the process.
It should show that port 3333 is open.
SSHing Into The Remote Machine.
Now that we have changed the port and re-started the SSH Service we need to SSH into the remote machine by using the following command with the -p 3333 arguments.
ssh root@192.168.1.32 -p 3333

