How to Easily Block IP Addresses From Accessing a Desktop or Server

We Keep you Connected

How to Easily Block IP Addresses From Accessing a Desktop or Server

How to Easily Block IP Addresses From Accessing a Desktop or Server
Your email has been sent
In this How to Make Tech Work tutorial, Jack Wallen shows how to add another layer of security to your Linux machines with just two files.
Did you know there’s a very easy way to block or allow IP addresses in Linux using two simple files? Those files are hosts.allow and hosts.deny, and they make it such that you can block or allow IP addresses on the fly without having to deal with more complicated firewall rules.
With this ability, you could quickly block a suspicious IP address to avoid possible malicious activity; or, you could limit, say, SSH connections to only specific addresses so you don’t have to worry about third parties gaining access to your servers or desktops. Let me show you how it’s done by demonstrating SSH access to a machine. The only things you’ll need for this are a running instance of Linux and a user with sudo privileges.
Log in to your Linux machine and open a terminal window. The first thing we’re going to do is deny all access to the SSH daemon. Open hosts.deny with the command sudo nano /etc/hosts.deny. At the bottom of that file, add sshd: ALL. Save and close the file.
Next, open hosts.allow with the command sudo nano /etc/hosts.allow. Let’s say you want to enable SSH access to only two machines on your network, which are at IP addresses 192.168.1.62 and 192.168.1.152; for that, at the bottom of the file, add the line sshd: 192.168.1.62, 192.168.1.152. Save and close the file.
At this point, the only two machines that are able to access your desktop or server via SSH are those two. Keep in mind that hosts.deny is read before hosts.allow so having sshd: ALL set to hosts.deny is only overridden if there’s an entry in hosts.allow. If you configure hosts.deny with ssdh: ALL and don’t add a corresponding entry in hosts.allow, no one will be allowed access, via SSH, to the machine.
And that’s all there is to using hosts.deny and hosts.allow to add another layer of security to your Linux machines.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.
Strengthen your organization’s IT security defenses by keeping abreast of the latest cybersecurity news, solutions, and best practices.
How to Easily Block IP Addresses From Accessing a Desktop or Server
Your email has been sent
Your message has been sent
TechRepublic Premium content helps you solve your toughest IT issues and jump-start your career or next project.
Microsoft is also running a grant competition for ideas on using AI training in community building.
Generative AI will be a game changer in cloud security, especially in common pain points like preventing threats, reducing toil from repetitive tasks, and bridging the cybersecurity talent gap.
Does your business need a payroll provider that offers international payroll services? Use our buyer’s guide to review the best solutions, from ADP to Oyster.
Get up and running with ChatGPT with this comprehensive cheat sheet. Learn everything from how to sign up for free to enterprise use cases, and start using ChatGPT quickly and effectively.
Looking for an alternative to monday.com? Our comprehensive list covers the best monday alternatives, their key features, pricing, pros, cons and more.
Strengthen your organization’s IT security defenses by keeping abreast of the latest cybersecurity news, solutions, and best practices.
C-level executives commonly present a unique combination of advanced permissions, mobility requirements and public personas that intensify the need to defend traditional attack surfaces. Therefore, it’s important to adopt a deliberate, standalone checklist to eliminate errors and best position new executives for productivity and success while also securing the firm’s data when they leave. The …
Knowing and thoroughly understanding the terminology associated with the metaverse will be vital to business decision makers as they assess whether a metaverse strategy will best serve their business needs and, if it does, how and when they will deploy it. This quick glossary from TechRepublic Premium provides a practical foundation for employees, managers and …
With the growing importance of big data for businesses, the need for database programs that are adaptable and scalable has become a priority. Enter MongoDB, an open-source database program that can accommodate a variety of programming languages. This download from TechRepublic Premium lists the salary, duties, education and desired competencies for a MongoDB Administrator. From …
A lax or non-existent corporate computer naming convention could make things more difficult when it comes to defining logical groups of computers and consistently targeting individual systems. This policy from TechRepublic Premium is designed to ensure every employee, contractor, temporary worker and volunteer understands and agrees to abide by specific guidelines for naming computers operating …

source

GET THE LATEST UPDATES, OFFERS, INFORMATION & MORE