How to change the port when connecting via SSH.

To change the port when connecting via SSH, you need to run the following commands:
Ubuntu
Open the SSH configuration file in a text editor:
sudo nano /etc/ssh/sshd_config
We are looking for the line #Port 22, under it we will add the line (the port you need) Port 4000
We save and exit the configuration file (Ctrl+X) And
restart the ssh service:
sudo service sshd restart
We allow incoming SSH connections on the server:
sudo ufw allow ssh
Opening the port:
sudo ufw allow 4000
If you need to close the default port, run the following command:
sudo ufw deny 22

 

Centos
Installing a text editor:
yum install nano
Open the SSH configuration file in a text editor:
nano /etc/ssh/sshd_config
We are looking for the line #Port 22, under it we will add the line (the port you need) Port 1234
Installing policycoreutils-python to resolve the port:
yum install -y policycoreutils-python
Now you need to allow this port to connect via SSH:
semanage port-a-t ssh_port_t-p tcp 1234
The firewall is enabled by default in the CentOS 7 system. Therefore, you need to add a rule to it:
firewall-cmd --add-port=1234/tcp --permanent
And restart:
firewall-cmd --reload
Performing a reboot of the ssh service:
systemctl restart sshd

  • 0 Корисниците го најдоа ова како корисно
Дали Ви помогна овој одговор?

Понудени резултати

How to get a trial period VPS / VDS?

We provide a test server for a period of up to 1 day.To receive trial period VPS / VDS you need:...

The reinstallation of the server via the VPS control panel

If you need to reinstall the operating system or change it to a different version, you can do...

Connection to the server through Remount Desktop

In order to allow the connection, you need to do the following: To get started, we connect to...

Hard disk volume check. How to Extend Drive in Windows.

To check the amount of hard disk space on the server, click the start menu, open Administrative...

Reinstallation CentOS 7 64bit

Go to the VPS Control Panel, select CentOS 7 64bit Minimal, check the box and click Reinstall....