What is a port?
A server can do many jobs at once. It can show websites, send email and accept logins. Each job listens at its own numbered door. That door is called a port. Think of a big building with many numbered doors.
What is port 22?
SSH stands for Secure Shell. It is a safe way to type commands on a remote server. By default, SSH listens on port 22. Programs that use SSH, such as SFTP (secure file transfer), also use port 22.
Because everyone knows this number, bad bots often knock on it. They try many passwords. That is why some people change the port.
How to connect on port 22
You do not need to type the port. SSH uses 22 on its own.
ssh username@your-server-address
This connects to your server on the default port.
How to connect on another port
Add -p and the number.
ssh -p 2222 username@your-server-address
This connects using port 2222. Your welcome email or Hostvento support can tell you which port your service uses.
How to change the SSH port (root access needed)
This part is for VPS and dedicated server owners. It needs root access. Root is the all-powerful admin user.
Warning: A wrong change can lock you out. Keep your current SSH window open until you have tested the new port. Also open the new port in your firewall first.
- Log in as root with SSH.
- Open the SSH settings file.
This opens the file in a simple editor.nano /etc/ssh/sshd_config - Find the line that starts with
#Port 22. - Change it to your new number and remove the
#. For example,Port 2222. - Save with Ctrl + O, press Enter, then exit with Ctrl + X.
- Restart the SSH service.
This applies the new setting.systemctl restart sshd - Open a second window and test the new port before you close the first one.
Quick recap
- A port is a numbered door on a server.
- SSH uses port 22 by default.
- Use
-pto connect to a different port. - Changing the port needs root access and care.
- Test the new port before closing your old session.