Below are the few steps :-
1) Open /etc/hosts.allow
Use the following command to open the hosts.allow file:
vi /etc/hosts.allow
Once this file is open, add the following line:
SSHD : ipaddress : ALLOW
2) Open /etc/hosts.deny
Use the following command to open the hosts.deny file:
vi /etc/hosts.deny
Once it opens, add the following line to the file:
SSHD : ALL : DENY
Save and exit, and you have successfully limited SSH access by IP address.
