Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # IP-Adresse des eingehenden SSH-Versuchs erhalten
- remote_ip=$(echo $SSH_CONNECTION | awk '{print $1}')
- # Geo-IP-Informationen von ip-api.com abrufen
- geo_info=$(curl -s "http://ip-api.com/json/$remote_ip")
- # Land aus den Geo-IP-Informationen extrahieren
- country=$(echo $geo_info | jq -r '.country')
- # Liste der erlaubten Länder (Deutschland, Nachbarländer und Spanien)
- allowed_countries=("Germany" "France" "Austria" "Switzerland" "Netherlands" "Belgium" "Luxembourg" "Denmark" "Czech Republic" "Poland" "Spain")
- # Prüfen, ob das Land des eingehenden SSH-Versuchs in der Liste der erlaubten Länder ist
- if [[ " ${allowed_countries[@]} " =~ " $country " ]]; then
- echo "SSH access from $country is allowed."
- exit 0
- else
- echo "SSH access from $country is blocked."
- exit 1
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement