In this tip we will see how to easily change the default SSH server port
number and making it running on multiple ports under Ubuntu 12.04
or older. The default SSH port number is 22, changing it to a
new port will help you avoid hackers' attack on this port. Installing an
SSH server under Ubuntu can be done with the following command:
sudo apt-get install openssh-server openssh-client
To change now the SSH server port number, follow these instructions:
- Via the command line, edit this file:
sudo gedit /etc/ssh/sshd_config
- Search for Port 22 and make sure it is uncommented, then set your own port number:
- To run your SSH server on multiple port numbers, add each port in a new line as follows:
Port 22
Port 33
Port 847
- Press now CTRL+Q and save your file, then restart your SSH server with this command so that your changes take effect:
sudo /etc/init.d/ssh restart
or
sudo service ssh restart
- You can now test your ports by running this command:
ssh -p PORT_NUMBER localhost
Here is an example:
ssh -p 22 localhost
If you are required to submit a password, then your SSH server is listening to this selected port.
Note: this tip is also workable for Ubuntu 11.04/10.10/10.04.
sudo apt-get install openssh-server openssh-client
To change now the SSH server port number, follow these instructions:
- Via the command line, edit this file:
sudo gedit /etc/ssh/sshd_config
- Search for Port 22 and make sure it is uncommented, then set your own port number:
- To run your SSH server on multiple port numbers, add each port in a new line as follows:
Port 22
Port 33
Port 847
- Press now CTRL+Q and save your file, then restart your SSH server with this command so that your changes take effect:
sudo /etc/init.d/ssh restart
or
sudo service ssh restart
- You can now test your ports by running this command:
ssh -p PORT_NUMBER localhost
Here is an example:
ssh -p 22 localhost
If you are required to submit a password, then your SSH server is listening to this selected port.
Note: this tip is also workable for Ubuntu 11.04/10.10/10.04.
No comments:
Post a Comment