Add ignore from file for authorized keys move
This commit is contained in:
@@ -65,12 +65,24 @@ if [ ${LIST} -eq 1 ]; then
|
|||||||
exit;
|
exit;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
|
# base folder
|
||||||
|
BASE_FOLDER=$(dirname $(readlink -f $0))"/";
|
||||||
|
# output printf
|
||||||
PRINTF_INFO="%-8s [%3s]: %-25s: %s\n";
|
PRINTF_INFO="%-8s [%3s]: %-25s: %s\n";
|
||||||
# list of user accounts we will never touch
|
# list of user accounts we will never touch
|
||||||
NO_ACTION=(root);
|
NO_ACTION=(root);
|
||||||
# move, but must check that master is set
|
# move, but must check that master is set
|
||||||
# master key is the first in the authorized keys list for the below users
|
# master key is the first in the authorized keys list for the below users
|
||||||
MASTER_KEY=(admin ec2-user ubuntu);
|
MASTER_KEY=(admin ec2-user ubuntu);
|
||||||
|
# skip user file
|
||||||
|
IGNORE_USER_FILE="../config/authorized_key_location_change.ignore"
|
||||||
|
# list of users to skip from file
|
||||||
|
IGNORE_USER=();
|
||||||
|
|
||||||
|
if [ -f "${BASE_FOLDER}${IGNORE_USER_FILE}" ]; then
|
||||||
|
readarray -t IGNORE_USER < "${BASE_FOLDER}${IGNORE_USER_FILE}";
|
||||||
|
echo "Reading ${IGNORE_USER_FILE}";
|
||||||
|
fi;
|
||||||
|
|
||||||
# loop over passwd file
|
# loop over passwd file
|
||||||
# if not in no action then check if .ssh/authorized_keys file exists
|
# if not in no action then check if .ssh/authorized_keys file exists
|
||||||
@@ -87,6 +99,10 @@ while read user_home; do
|
|||||||
printf "${PRINTF_INFO}" "SKIP" "*" "${username}" "skip forced via command line";
|
printf "${PRINTF_INFO}" "SKIP" "*" "${username}" "skip forced via command line";
|
||||||
continue;
|
continue;
|
||||||
fi;
|
fi;
|
||||||
|
if [[ " ${IGNORE_USER[*]} " =~ " ${username} " ]]; then
|
||||||
|
printf "${PRINTF_INFO}" "SKIP" "**" "${username}" "skip from ignore config file";
|
||||||
|
continue;
|
||||||
|
fi;
|
||||||
home_folder=$(echo "${user_home}" | cut -d ":" -f 2);
|
home_folder=$(echo "${user_home}" | cut -d ":" -f 2);
|
||||||
# skip no .ssh/authorized_ekys
|
# skip no .ssh/authorized_ekys
|
||||||
if [ ! -f "${home_folder}/.ssh/authorized_keys" ]; then
|
if [ ! -f "${home_folder}/.ssh/authorized_keys" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user