Change SSH Port Number

Configure Firewall

First, you should allow a secret port number to access the server.

$ sudo ufw allow 80022
$ sudo ufw reload

Configure SSHd Setting

$ sudo vi /etc/ssh/sshd_config

Edit the “Port” option to your allowed port number.

Port 80022

Restart SSHd server

$ sudo systemctl restart sshd

Edit local config file

Edit the configuration file on the local machine.

$ vi ~/.ssh/config
Host raspberrypi
    HostName 192.168.10.108
    IdentifyFiles ~/.ssh/id_rsa
    User <<user-name>>
    Port 80022

Login with config file

$ ssh raspberrypi

Delete rule of 22 port

$ sudo ufw status numbered
$ sudo ufw delete <<Rule number for Port 22>>

Last Updated on July 8, 2021 by lama-admin


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *