{"id":15003288,"url":"https://github.com/toulisdev/fail2ban-action-mssql","last_synced_at":"2025-08-27T07:22:29.964Z","repository":{"id":173077993,"uuid":"469748051","full_name":"ToulisDev/fail2ban-action-mssql","owner":"ToulisDev","description":"Fail2ban action for adding banned ips to your MS SQL Server. This is how to add ban ips from fail2ban to SQL Server or MS SQL Server. MS SQL Server Action for Fail2ban. Fail2ban action for ms sql server","archived":false,"fork":false,"pushed_at":"2022-08-30T17:00:32.000Z","size":4,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T14:50:32.874Z","etag":null,"topics":["fail2ban","fail2ban-action","fail2ban-filter","ms-sql","ms-sql-server","ms-sql-server-action","ms-sql-server-action-fail2ban","ms-sql-server-action-for-fail2ban","mssql","mssql-database","mssqlserver","shell-script","sql","sql-server"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ToulisDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-14T13:35:05.000Z","updated_at":"2024-09-23T11:04:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"ea8a838e-e352-49ac-996e-332c4ee79b4c","html_url":"https://github.com/ToulisDev/fail2ban-action-mssql","commit_stats":null,"previous_names":["toulisdev/fail2ban-action-mssql"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ToulisDev/fail2ban-action-mssql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToulisDev%2Ffail2ban-action-mssql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToulisDev%2Ffail2ban-action-mssql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToulisDev%2Ffail2ban-action-mssql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToulisDev%2Ffail2ban-action-mssql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ToulisDev","download_url":"https://codeload.github.com/ToulisDev/fail2ban-action-mssql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToulisDev%2Ffail2ban-action-mssql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272303738,"owners_count":24910440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-27T02:00:09.397Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fail2ban","fail2ban-action","fail2ban-filter","ms-sql","ms-sql-server","ms-sql-server-action","ms-sql-server-action-fail2ban","ms-sql-server-action-for-fail2ban","mssql","mssql-database","mssqlserver","shell-script","sql","sql-server"],"created_at":"2024-09-24T18:57:52.730Z","updated_at":"2025-08-27T07:22:29.920Z","avatar_url":"https://github.com/ToulisDev.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MS SQL Server Action for fail2ban\nThis is a script to add banned ips from fail2ban to your MS SQL server using ban-action from fail2ban. (Tested on Ubuntu Server)\n\n## Requirements\nYou have to get mssql-tools and fail2ban to get this script running.\n```\nsudo apt-get update\nsudo apt-get install mssql-tools fail2ban\n```\n\n## Installation\n\n### Step 1:\nCreate a database to your MS SQL Server named fail2ban and create a user fail2ban that has write/update permission to database (You can give dbowner permission too).\n\n### Step 2:\nDownload the \".my.cnf-fail2ban\" file using sudo permision and edit it with your favourite text editor.\nYou should change the ```\u003cchange me\u003e``` with your password of user fail2ban.\nAfter changing the password move the file to /root/ folder.\n\n```\nsudo wget https://raw.githubusercontent.com/ToulisDev/fail2ban-action-mssql/main/.my.cnf-fail2ban\nsudo nano ./.my.cnf-fail2ban\nsudo mv ./.my.cnf-fail2ban /root/.my.cnf-fail2ban\n```\n### Step 3:\nDownload config file for fail2ban service and move it to \"/etc/fail2ban/action.d/\" folder.\n\n```\nwget https://raw.githubusercontent.com/ToulisDev/fail2ban-action-mssql/main/banned_db.conf\nmv ./banned_db.conf /etc/fail2ban/action.d/banned_db.conf\n```\n### Step 4:\nDownload the \"fail2ban_banned_db\" bash script, give chmod 0550 permission and move the file to \"/usr/local/bin/fail2ban_banned_db\".\n\n```\nsudo wget https://raw.githubusercontent.com/ToulisDev/fail2ban-action-mssql/main/fail2ban_banned_db\nsudo chmod 0550\nsudo mv ./fail2ban_banned_db /usr/local/bin/fail2ban_banned_db\n```\n### Step 5:\nAdd action to your \"/etc/fail2ban/jail.local\" file. Example:\n\n```\n[mssqld]\nenabled = true\nlogpath = /var/opt/mssql/log/errorlog\nmaxfailures = 3\nfindtime = 600\nbantime = 672h\nfilter = mssqld-auth\nport = 1433\naction = iptables-allports\n         banned_db[name=mssqld, port=\"All-ports\", protocol=tcp]     \u003c--- name,port, protocol are optional you can add the action just with \"banned_db\"\n```\n\nAnd finally, restart your fail2ban-client.\n```sudo fail2ban-client restart```\n\n\n\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoulisdev%2Ffail2ban-action-mssql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoulisdev%2Ffail2ban-action-mssql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoulisdev%2Ffail2ban-action-mssql/lists"}