• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to block SSH access for client host

1160

How to block SSH access for client host

In this tutorial we are going to explain how to block SSH access for client hosts to secure the server. SSH is a network protocol that connects network services and provides a secured connection over a network in client-server architecture.

Steps to block SSH access

To Block the SSH access to the client host, open the hosts.deny file and add the host ip to block and save the file.

 [root@linuxhelp1 ~]# vim /etc/hosts.deny
sshd:192.168.7.232

After saving the file, restart and enable the ssh service by entering the command.

[root@linuxhelp1 ~]# systemctl restart sshd.service
[root@linuxhelp1 ~]# systemctl enable sshd.service

Now the SSH service is restarted and enabled. Now add the ssh service into firewall.

[root@linuxhelp1 ~]# firewall-cmd --permanent --add-service=ssh
Success

Run the following command to reload the firewall in the SSH.

[root@linuxhelp1 ~]# firewall-cmd --reload
Success

The firewall is successfully enabled. Enter the IP address to login to client machine now take ssh .

[root@linuxhelp2 ~]# ssh root@192.168.7.232
ssh_exchange_identification: read: Connection reset by peer

The IP address is blocked by the firewall. Now block the entire ip from specific network.

[root@linuxhelp1 ~]# vim /etc/hosts.deny
sshd:192.168.7.

Restart the ssh service.

[root@linuxhelp1 ~]# systemctl restart sshd.service

From a different client host, take the ssh from different ip based on the blocked network.

[root@localhost ~]# ssh root@192.168.7.232
ssh_exchange_identification: Connection closed by remote host

To block ssh access for different networks or client hosts.Run the following command.

[root@linuxhelp1 ~]# vim /etc/hosts.deny
sshd:192.168.7.,192.168.5.

Run the command to restart the service.

[root@linuxhelp1 ~]# systemctl restart sshd.service

To block the ssh from different account. Enter the command.

[root@linuxhelp1 ~]# ssh root@192.168.7.232
ssh_exchange_identification: Connection closed by remote host

To check the ssh log from the server. enter the command and hit " enter" . This shows the list of blocked SSH services lists.

[root@linuxhelp1 ~]# tail -f /var/log/secure
Feb  9 18:07:12 linuxhelp1 sshd[11492]: refused connect from 192.168.7.254 (192.168.7.254)
Feb  9 18:07:23 linuxhelp1 sshd[11499]: refused connect from 192.168.5.182 (192.168.5.182)
Feb  9 18:07:34 linuxhelp1 sshd[11500]: refused connect from 192.168.7.150 (192.168.7.150)

Tags:
jacob
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

Provide some commands to check who accessed via ssh?

A

Following command is used to check the access file of SSH
Yes use "w -I" aureport or "/var/log/secure"

Q

How to create the public key pair for authentication?

A

ssh-keygen - creates a key pair for public key authentication.

Q

What is the syntax for adding ssh service deny in host.deny?

A

Following syntax is used to add the ssh service
sshd:list of IP addresses seperated by comma

Q

How to create the public key pair for authentication?

A

ssh-keygen - creates a key pair for public key authentication in SSH.

Q

What is sftp in SSH to access the file?

A

sftp - file transfer client with FTP-like command interface in Superuser

Related Tutorials in How to block SSH access for client host

Related Tutorials in How to block SSH access for client host

How to add Host into Nagios Server
How to add Host into Nagios Server
Nov 1, 2016
How To Restrict SFTP Users Home Directories in Linux
How To Restrict SFTP Users Home Directories in Linux
Jun 4, 2016
How To Set Email Alerts for SSH Root Login In Linux
How To Set Email Alerts for SSH Root Login In Linux
Jun 22, 2016
How to add SSH key to a GitLab account
How to add SSH key to a GitLab account
Apr 22, 2017
How to block SSH access for client host
How to block SSH access for client host
Feb 13, 2017
SSH Command in Linux with Examples
SSH Command in Linux with Examples
Mar 22, 2016
How to add Linux Host in Zabbix Server on CentOS
How to add Linux Host in Zabbix Server on CentOS
Nov 5, 2016
How to install Autossh on Ubuntu 16.04
How to install Autossh on Ubuntu 16.04
May 3, 2017

Related Forums in How to block SSH access for client host

Related Forums in How to block SSH access for client host

SSH
isaac class=
How to block ssh port in iptables
Aug 29, 2017
OpenSSH
caden class=
Warning Remote Host Identification Has Changed!
Feb 6, 2017
CentOS
philippe class=
Cannot start sshd service
Feb 15, 2018
SSH
carter class=
how to use nautilus in ssh server
May 27, 2017
SSH
symonds class=
How to access ssh from web browser
Nov 2, 2017
SSH
jayce class=
How to prevent ssh brute force attack
Aug 29, 2017
SSH
luke class=
Where are my sshd logs is placed.
Aug 29, 2017
SSH
kannan_raja class=
How to make password less ssh login
Feb 22, 2017
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help legeek ?
Installation of the call center module

hello

I wish to install a call center in virtual with issabel, I downloaded the latest version of it , but I don' t arrive to install the call center module in issabel. please help me

thanks!

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.