Ganti Port SSH di Ubuntu 18.04

 

How to Change SSH Port in Ubuntu 18.04

check port default ssh yang udah digunakan

netstat -tulnp | grep ssh
run the netstat command to check ssh port currently running on

As you can see, the SSH daemon is currently running on TCP port 22.

cek konfigurasi saat ini

grep -i port /etc/ssh/sshd_config

The Port directive is commented out by default, which means SSH daemon listens on  the default port 22.

The Port directive of the sshd_config config file specifies the port number that ssh server listens on

If you want to change the default SSH port in Ubuntu, perform the following steps with root privileges:

  1. Open the /etc/ssh/sshd_config file and locate the line:
    #Port 22
  2. Then, uncomment (Remove the leading # character) it and change the value with an appropriate port number (for example, 22000):
    Port 22000
  3. Restart the SSH server:
    systemctl restart sshd

After that, run the netstat command and make sure that the ssh daemon now listen on the new ssh port:

netstat -tulpn | grep ssh

When connecting to the server using the ssh command, you need to specify the port to connect using the -p flag:

ssh -p 22000 192.168.1.100

Note that if the Firewall is enabled, you need to add a rule to allow new SSH port.

Komentar

Postingan populer dari blog ini

Cara menambahkan IP address untuk VPCS di GNS3