• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Install, Configure PyFilter to Control Illegitimate SSH Login Attempts

By Abhishek Ghosh April 6, 2018 7:44 pm Updated on April 25, 2018

Install, Configure PyFilter to Control Illegitimate SSH Login Attempts

Advertisement

There are various intrusion prevention software available to prevent brute-force attacks. Here is How to Install, Configure PyFilter to Control Illegitimate SSH Login Attempts. PyFilter project is sponsored by Digital Ocean and developed by individual developer as Free Software under GNU GPL 3.0 License. PyFilter has own Github repo, own website. I guess a question will arise in mind – why not Fail2Ban but PyFilter? PyFilter has PyFilter-Admin which provides statistical information including total bans which is not easy to setup with Fail2Ban (we have shown configuration with Badips with Fail2Ban for analytics). As it is modern, written in Python, in future we hope that we can easily implement Big Data analysis tools with it or create a WordPress Plugin. There is nothing wrong to test different prevention software. Fail2Ban of course time tested, powerful but never just easy even for an used sysadmin to handle. There are actually more bigger hammers for intrusion prevention, but commonly our need is limited to LAMP/LEMP servers and SSH. Here is official website and official GitHub repo of PyFilter :

Vim
1
2
https://pyfilter.co.uk/
https://github.com/Jason2605/PyFilter

Here is PyFilter Admin :

Vim
1
https://github.com/Jason2605/PyFilter-Admin

Developer has written guide on Digital Ocean and official website. We are combining PyFilter and PyFilter-Admin in this guide.

Advertisement

---

Remember : If you get wrongly locked-in, you need to either login to web admin console of webhost to flash iptables or request your webhost to do so. We will suggest to use our method to use cron to flash iptables every 5 minutes during testing if your web admin console of webhost has no web based SSH (that is not uncommon among OpenVZ servers). As we told before – before throwing stones towards hackers, you should be careful. Do not run Fail2Ban or DenyHost with PyFilter.

Install, Configure PyFilter to Control Illegitimate SSH Login Attempts

 

Install, Configure PyFilter to Control SSH Login Attempts

 

PyFilter needs Python 3. Python 3 is by default installed on Ubuntu 16.04 (and will be on Ubuntu 18.04 LTS). For single server installation, you simply need to clone the GitHub repo :

Vim
1
2
3
cd ~
git clone https://github.com/Jason2605/PyFilter.git
ls -al

You’ll see a directory named PyFilter.git. You will move that directory to /usr/local/ :

Vim
1
2
sudo mv PyFilter /usr/local/PyFilter
cd /usr/local/PyFilter

Next, work on the configuration files :

Vim
1
2
sudo cp Config/config.default.json Config/config.json
cat Config/config.json

You’ll see the defaults settings as output. You can change the settings as per your need. This is default config file :

Vim
1
https://github.com/Jason2605/PyFilter/blob/master/Config/config.default.json

Add your server’s IP or VPN’s IP in "ignored_ips": ["127.0.0.1"], during testing. Last step is simply executing the script and creating system service :

Vim
1
2
3
4
5
sudo chmod +x run.sh
./run.sh
## create service
sudo chmod +x install.sh
./install.sh

Now, if you run :

Vim
1
sudo systemctl status PyFilter

You’ll get normal expected output like any other system service. We need to install GEOIP, which is optional unless you need the name of countries.

Vim
1
2
## pip install geoip2
pip3 install geoip2

If you face error, that is not strange. If you face error, ask on StackOverflow. Not everything on this earth has explainable reason!

For using PyFilter-Admin and manually add IPs via it, you need Redis :

Vim
1
2
pip3 install redis
nano Config/config.json

Find the line "database": "sqlite" and change it to "database": "redis". This will be the config :

Vim
1
2
3
4
5
6
7
8
9
10
  "redis": {
    "host": "127.0.0.1",
    "password": null,
    "database": 0,
    "sync_bans": {
      "active": true,
      "name": "your_hostname",
      "check_time": 600
    }
  },

Restart PyFilter like any other service and check status :

Vim
1
2
sudo systemctl restart PyFilter
sudo systemctl status PyFilter

It is better to install PyFilter-Admin on development server first to test than running on LAMP server with production WordPress like site. For running PyFilter-Admin, run these commands :

Vim
1
2
3
git clone https://github.com/Jason2605/PyFilter-Admin
pip install -r requirements.txt
python run_server.py

Default username is PyFilter The default password is PyFilter12345. Just to remind, for Django we run :

Vim
1
python manage.py runserver your-server-ip:8000

Then navigate to the admin panel’s URL in a browser like :

Vim
1
http://your-server-ip:8000/admin/

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Install, Configure PyFilter to Control Illegitimate SSH Login Attempts

  • Configure Apache With Fail2Ban on Ubuntu 18.04

    Here is How To Configure Apache With Fail2Ban on Ubuntu 18.04 to block more types of malicious attempts towards server to create a practical firewall.

  • WordPress & PHP : Different AdSense Units on Mobile Devices

    Here is How To Serve Different AdSense Units on Mobile Devices on WordPress With PHP. WordPress Has Function Which Can Be Used In Free Way.

  • Fail2ban GeoIP Action Script to Block SSH by Country

    Instead of Using Bash Script to Restrict SSH by Countries Based on GeoIP, We Can Create Fail2ban GeoIP Action Script to Block SSH by Country.

  • iptables Basics : Chapter 3, Configuring Fail2Ban With WordPress

    iptables Basics Chapter 3 Describes Configuring Fail2Ban With WordPress to Give Ultimate Protection. Thus We Secured OSI Model’s All Layers.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy