Watch all our Tutorials and Training Videos for Free on our Youtube Channel, Get Online Web Tools for Free on swebtools.com

Search Suggest

How to Set SSH Port in Ubuntu?

How to Set SSH Port in Ubuntu, ?, DevOps, Linux, Server
How to Set SSH Port in Ubuntu

SSH, or Secure Shell, is a popular network protocol used to remotely access and manage servers. By default, SSH uses port 22 for communication, but it's recommended to change this default port to improve security. In this article, we'll explore how to set SSH port in Ubuntu.

Step 1: Connect to your Ubuntu Server

To get started, connect to your Ubuntu server via SSH as a sudo user.

Step 2: Open the SSH configuration file

Once connected, open the SSH configuration file using the following command:

sudo nano /etc/ssh/sshd_config

Step 3: Change the SSH port number

In the SSH configuration file, locate the line that specifies the port number, which is usually set to 22. To change the SSH port, simply replace the number 22 with your desired port number. For example, let's say you want to use port number 1234. The line would now look like this:

Port 1234

Save the file and exit the editor.

Step 4: Restart SSH Service

To apply the changes, restart the SSH service using the following command:

sudo systemctl restart sshd

Step 5: Verify SSH connection with the new port number

To verify that SSH is using the new port number, try to connect to the server using the new port number. For example, if you changed the port number to 1234, use the following command to connect:

ssh username@server-ip-address -p 1234

Congratulations! You have successfully changed the SSH port number in Ubuntu.

More Examples:

  • If you want to use a port number other than the reserved system ports (0-1023), choose a number between 1024 and 65535.
  • If you're using a firewall, make sure to open the new SSH port number in your firewall settings.

So, changing the default SSH port is a simple and effective way to improve the security of your server. By following the steps outlined in this article, you can easily set a new SSH port number on your Ubuntu server.

Related Searches and Questions asked:

  • How to Use SSH in Ubuntu?
  • How to Use SSH on Linux?
  • How to Do SSH in EC2?
  • How to Use SSH on AWS?
  • That's it for this post. Keep practicing and have fun. Leave your comments if any.