Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/banlist #61

Merged
merged 6 commits into from
Oct 4, 2024
Merged

Feat/banlist #61

merged 6 commits into from
Oct 4, 2024

Conversation

dexter21767-dev
Copy link
Member

@dexter21767-dev dexter21767-dev commented Sep 13, 2024

add an option to ban users according to a list of users.

TODO: set the location of BAN_LIST

Copy link
Member Author

@dexter21767-dev dexter21767-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

script for updating the current authorized-keys file

#!/bin/bash

# Path to the file
AUTH_KEYS_PATH="$HOME/.ssh/authorized_keys"

# Temporary file to store updated content
TEMP_FILE=$(mktemp)

# Read the file line by line
while IFS= read -r line; do
    if [[ "$line" =~ GITHUB_USER=\'([^\']+)\' ]]; then
        # Extract the current GITHUB_USER value using regex capture group
        current_value="${BASH_REMATCH[1]}"
        # Update the value using the function
        updated_value=$(echo "$current_value" | shasum -a 256 | cut -c1-12)

        # Replace the GITHUB_USER value in the line
        updated_line=$(echo "$line" | sed "s/GITHUB_USER='$current_value'/GITHUB_USER='$updated_value'/")
        echo "$updated_line"
    else
        # Write the line as is
        echo "$line"
    fi
done < "$AUTH_KEYS_PATH" > "$AUTH_KEYS_PATH.tmp"


# Replace the original file with the updated content
mv "$AUTH_KEYS_PATH.tmp" "$AUTH_KEYS_PATH"

echo "File updated successfully."

@gcalcaterra gcalcaterra merged commit 1fe53da into development Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants