Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
935d6a84c9 | ||
|
|
83f84abd46 | ||
|
|
090d6f9cec | ||
|
|
5659cc010f | ||
|
|
0bd40cdd73 | ||
|
|
5bf30a8b2f | ||
|
|
26c007dba6 | ||
|
|
785e3c116d | ||
|
|
adbfeb0074 | ||
|
|
8c7ef32894 | ||
|
|
70ef7a3fc5 | ||
|
|
89252af50b | ||
|
|
8fb833d3c4 | ||
|
|
694f04313c | ||
|
|
50e28c7cfd | ||
|
|
65b7a6ad43 | ||
|
|
244461d466 | ||
|
|
66213dfd65 | ||
|
|
39da44b546 | ||
|
|
d4bb06e3e1 | ||
|
|
cc647de495 |
2
.shellcheckrc
Normal file
2
.shellcheckrc
Normal file
@@ -0,0 +1,2 @@
|
||||
shell=bash
|
||||
external-sources=true
|
||||
34
Readme.md
34
Readme.md
@@ -26,6 +26,31 @@ Inside the base folder there are
|
||||
- ssh-keygen for temporary holding the PEM/PUB files
|
||||
- zip file which holds the created user list, password and PEM/PUB files
|
||||
|
||||
## Config
|
||||
|
||||
### create_user.sh: create_user.cfg
|
||||
|
||||
A `create_user.cfg` can be created to set a differen HOME_LOCATION and PASSWORD_LENGTH values
|
||||
|
||||
eg:
|
||||
|
||||
```ini
|
||||
HOME_LOCATION="/storage"
|
||||
PASSWORD_LENGTH=14
|
||||
```
|
||||
|
||||
### authorized_key_location_change.sh: authorized_key_location_change.ignore
|
||||
|
||||
For this script a `authorized_key_location_change.ignore` with a list of user names to ignore for the
|
||||
move
|
||||
|
||||
eg:
|
||||
|
||||
```ini
|
||||
foo_user
|
||||
bar_user
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### -g (go)
|
||||
@@ -297,13 +322,8 @@ some.host,name_b,staff,sshallow,2021-11-15,767,2023-12-20 22:18:36,1,ssh,false,O
|
||||
"SubGroups": [
|
||||
"sudo",
|
||||
"users",
|
||||
"ikea",
|
||||
"harley",
|
||||
"aeon",
|
||||
"primaham",
|
||||
"nisshin",
|
||||
"nissan",
|
||||
"pfizer"
|
||||
"group_a",
|
||||
"group_b",
|
||||
],
|
||||
"AccountCreatedDate": "2021-11-15",
|
||||
"AccountAge": "767",
|
||||
|
||||
@@ -27,12 +27,24 @@ LOG="${BASE_FOLDER}/../log";
|
||||
# auth log file user;date from collect_login_data script
|
||||
AUTH_LOG="${BASE_FOLDER}/../auth-log/user_auth.log";
|
||||
|
||||
error=0;
|
||||
if [ $(whoami) != "root" ]; then
|
||||
echo "Script must be run as root user";
|
||||
exit;
|
||||
error=1;
|
||||
fi;
|
||||
if [ ! -d "${LOG}" ]; then
|
||||
echo "log folder ${LOG} not found";
|
||||
error=1;
|
||||
fi;
|
||||
if [ -z $(command -v curl) ]; then
|
||||
echo "Missing curl application, aborting";
|
||||
error=1;
|
||||
fi;
|
||||
if [ -z $(command -v jq) ]; then
|
||||
echo "Missing jq application, aborting";
|
||||
error=1;
|
||||
fi;
|
||||
if [ $error -eq 1 ]; then
|
||||
exit;
|
||||
fi;
|
||||
# option 1 in list
|
||||
@@ -45,25 +57,41 @@ case "${1,,}" in
|
||||
echo "{";
|
||||
;;
|
||||
csv)
|
||||
CSV_LINE="%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n";
|
||||
OUTPUT_TARGET="csv";
|
||||
echo "Hostname,Username,Main Group,SSH Group,Account Created Date,Account Age,Last Login Date,Last Login Age,Never Logged In,Login Source,Status";
|
||||
echo "Account ID,Region,Instance ID,Hostname,Username,Main Group,SSH Group,Account Created Date,Account Age,Last Login Date,Last Login Age,Never Logged In,Login Source,Status";
|
||||
;;
|
||||
*)
|
||||
OUTPUT_TARGET="text";
|
||||
;;
|
||||
esac;
|
||||
|
||||
if [ "${OUTPUT_TARGET}" == "text" ]; then
|
||||
# collect info via: curl http://169.254.169.254/latest/meta-data/
|
||||
instance_data=$(
|
||||
TOKEN=`curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` &&
|
||||
curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/dynamic/instance-identity/document
|
||||
)
|
||||
instance_id=$(echo "${instance_data}" | jq .instanceId)
|
||||
account_id=$(echo "${instance_data}" | jq .accountId)
|
||||
region=$(echo "${instance_data}" | jq .region)
|
||||
|
||||
if [ "${OUTPUT_TARGET}" = "text" ]; then
|
||||
LOG="${LOG}/check_ssh_user."$(date +"%F_%H%m%S")".log";
|
||||
exec &> >(tee -a "${LOG}");
|
||||
echo "[START] =============>";
|
||||
echo "AWS ID : ${account_id}";
|
||||
echo "Region : ${region}";
|
||||
echo "Instance ID : ${instance_id}";
|
||||
echo "Hostname : "$(hostname);
|
||||
echo "Run date : "$(date +"%F %T");
|
||||
echo "Max age last login : ${max_age_login} days";
|
||||
echo "Warn age last login: ${warn_age_login} days";
|
||||
echo "Max age no login : ${max_age_create} days";
|
||||
elif [ "${OUTPUT_TARGET}" == "json" ]; then
|
||||
elif [ "${OUTPUT_TARGET}" = "json" ]; then
|
||||
echo '"Info": {'
|
||||
echo '"AccountId": '${account_id}',';
|
||||
echo '"Region": '${region}',';
|
||||
echo '"InstanceId": '${instance_id}',';
|
||||
echo '"Hostname": "'$(hostname)'",';
|
||||
echo '"Date": "'$(date +"%F %T")'",';
|
||||
echo '"MaxAgeLogin": '${max_age_login}',';
|
||||
@@ -73,9 +101,9 @@ elif [ "${OUTPUT_TARGET}" == "json" ]; then
|
||||
echo '"Users": ['
|
||||
fi;
|
||||
for ssh_group in ${ssh_groups[@]}; do
|
||||
if [ "${OUTPUT_TARGET}" == "text" ]; then
|
||||
if [ "${OUTPUT_TARGET}" = "text" ]; then
|
||||
echo "--------------------->"
|
||||
if [ "${ssh_group}" == "${ssh_reject_group}" ]; then
|
||||
if [ "${ssh_group}" = "${ssh_reject_group}" ]; then
|
||||
echo "Showing current SSH Reject users:";
|
||||
unlock_flag=1
|
||||
else
|
||||
@@ -106,13 +134,13 @@ for ssh_group in ${ssh_groups[@]}; do
|
||||
echo "}";
|
||||
;;
|
||||
csv)
|
||||
printf "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n" "$(hostname)" "${username}" "" "${ssh_group}" "" "" "" "" "true" "${out_string}"
|
||||
printf "${CSV_LINE}" "${account_id}" "${region}" "${instance_id}" "$(hostname)" "${username}" "" "${ssh_group}" "" "" "" "" "true" "${out_string}"
|
||||
;;
|
||||
esac;
|
||||
continue;
|
||||
fi;
|
||||
# for json output, we need , between outputs
|
||||
if [ "${OUTPUT_TARGET}" == "json" ] && [ $first_run -eq 0 ]; then
|
||||
if [ "${OUTPUT_TARGET}" = "json" ] && [ $first_run -eq 0 ]; then
|
||||
echo ",";
|
||||
fi;
|
||||
first_run=0;
|
||||
@@ -131,14 +159,25 @@ for ssh_group in ${ssh_groups[@]}; do
|
||||
# check user create time, if we have set it in comment
|
||||
user_create_date_string=$(cat /etc/passwd | grep "${username}:" | cut -d ":" -f 5);
|
||||
# if empty try last password set time
|
||||
if [ -z "${user_create_date_string}" ]; then
|
||||
if ! [[ "${user_create_date_string}" =~ ^\d{4}-\d{2}-\{2} ]]; then
|
||||
# user L 11/09/2020 0 99999 7 -1
|
||||
user_create_date_string=$(passwd -S ${username} | cut -d " " -f 3);
|
||||
fi;
|
||||
# last try is user home .bash_logout
|
||||
if [ -z "${user_create_date_string}" ]; then
|
||||
home_dir=$(cat /etc/passwd | grep "${username}:" | cut -d ":" -f 6)"/.bash_logout";
|
||||
user_create_date_string=$(stat -c %Z "${home_dir}");
|
||||
if ! [[ "${user_create_date_string}" =~ ^\d{4}-\d{2}-\{2} ]]; then
|
||||
# try logout or bash history
|
||||
home_dir_bl=$(cat /etc/passwd | grep "${username}:" | cut -d ":" -f 6)"/.bash_logout";
|
||||
home_dir_bh=$(cat /etc/passwd | grep "${username}:" | cut -d ":" -f 6)"/.bash_history";
|
||||
# check that this file exists
|
||||
if [ -f "${home_dir_bl}" ]; then
|
||||
user_create_date_string=$(stat -c %Z "${home_dir_bl}");
|
||||
elif [ -f "${home_dir_bh}" ]; then
|
||||
user_create_date_string=$(stat -c %Z "${home_dir_bh}");
|
||||
fi;
|
||||
fi;
|
||||
# still no date -> set empty
|
||||
if ! [[ "${user_create_date_string}" =~ ^\d{4}-\d{2}-\{2} ]]; then
|
||||
user_create_date_string="";
|
||||
fi;
|
||||
|
||||
# below only works if the user logged in, a lot of them are just file upload
|
||||
@@ -158,7 +197,7 @@ for ssh_group in ${ssh_groups[@]}; do
|
||||
found=$(grep "${username};" "${AUTH_LOG}");
|
||||
fi;
|
||||
# always pre work account dates if they exist, but output only if text
|
||||
if [ -z "${found}" ] && [ ! -z "${user_create_date_string}" ]; then
|
||||
if [ ! -z "${user_create_date_string}" ]; then
|
||||
user_create_date=$(echo "${user_create_date_string}" | date +"%s" -f -);
|
||||
# if all empty, we continue with only check if user has last login date
|
||||
# else get days since creation
|
||||
@@ -172,9 +211,11 @@ for ssh_group in ${ssh_groups[@]}; do
|
||||
last_login=$(awk '{printf("%.0f\n",($1-$2)/$3)}' <<<"${now} ${last_login_date} ${day}");
|
||||
if [ ${last_login} -gt ${max_age_login} ]; then
|
||||
out_string="[!] last ssh log in ${last_login} days ago";
|
||||
lock_user=1;
|
||||
if [ "${ssh_group}" != "${ssh_reject_group}" ]; then
|
||||
lock_user=1;
|
||||
fi;
|
||||
elif [ ${last_login} -gt ${warn_age_login} ]; then
|
||||
out_string="OK [last ssh login ${last_login} days ago";
|
||||
out_string="OK [last ssh login ${last_login} days ago]";
|
||||
else
|
||||
out_string="OK [ssh]";
|
||||
fi;
|
||||
@@ -190,9 +231,11 @@ for ssh_group in ${ssh_groups[@]}; do
|
||||
last_login=$(awk '{printf("%.0f\n",($1-$2)/$3)}' <<<"${now} ${last_login_date} ${day}");
|
||||
if [ ${last_login} -gt ${max_age_login} ]; then
|
||||
out_string="[!] last terminal log in ${last_login} days ago";
|
||||
lock_user=1;
|
||||
if [ "${ssh_group}" != "${ssh_reject_group}" ]; then
|
||||
lock_user=1;
|
||||
fi;
|
||||
elif [ ${last_login} -gt ${warn_age_login} ]; then
|
||||
out_string="OK [last terminal login ${last_login} days ago";
|
||||
out_string="OK [last terminal login ${last_login} days ago]";
|
||||
else
|
||||
out_string="OK [lastlog]";
|
||||
fi;
|
||||
@@ -201,7 +244,9 @@ for ssh_group in ${ssh_groups[@]}; do
|
||||
elif [ ! -z "${user_create_date}" ]; then
|
||||
if [ ${account_age} -gt ${max_age_create} ]; then
|
||||
out_string="[!] Never logged in: account created ${account_age} days ago";
|
||||
lock_user=1;
|
||||
if [ "${ssh_group}" != "${ssh_reject_group}" ]; then
|
||||
lock_user=1;
|
||||
fi;
|
||||
else
|
||||
out_string="OK [Never logged in]";
|
||||
fi;
|
||||
@@ -211,7 +256,7 @@ for ssh_group in ${ssh_groups[@]}; do
|
||||
never_logged_in="true";
|
||||
fi;
|
||||
# build delete output
|
||||
if [ ${lock_user} = 1 ]; then
|
||||
if [ ${lock_user} -eq 1 ]; then
|
||||
lock_accounts="${lock_accounts} ${username}"
|
||||
fi;
|
||||
case "${OUTPUT_TARGET}" in
|
||||
@@ -222,7 +267,7 @@ for ssh_group in ${ssh_groups[@]}; do
|
||||
sub_groups_string="["
|
||||
sub_group_first=1
|
||||
for s_group in $sub_groups; do
|
||||
if [ "${sub_group_first}" == 0 ]; then
|
||||
if [ "${sub_group_first}" = 0 ]; then
|
||||
sub_groups_string="${sub_groups_string},";
|
||||
fi;
|
||||
sub_groups_string="${sub_groups_string}\"${s_group}\"";
|
||||
@@ -244,12 +289,12 @@ for ssh_group in ${ssh_groups[@]}; do
|
||||
echo "}";
|
||||
;;
|
||||
csv)
|
||||
printf "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n" "$(hostname)" "${username}" "${main_group}" "${ssh_group}" "${user_create_date_out}" "${account_age}" "${last_login_date}" "${last_login}" "${never_logged_in}" "${login_source}" "${out_string}"
|
||||
printf "${CSV_LINE}" "${account_id}" "${region}" "${instance_id}" "$(hostname)" "${username}" "${main_group}" "${ssh_group}" "${user_create_date_out}" "${account_age}" "${last_login_date}" "${last_login}" "${never_logged_in}" "${login_source}" "${out_string}"
|
||||
;;
|
||||
esac;
|
||||
done;
|
||||
done;
|
||||
if [ "${OUTPUT_TARGET}" == "text" ]; then
|
||||
if [ "${OUTPUT_TARGET}" = "text" ]; then
|
||||
if [ ! -z "${lock_accounts}" ]; then
|
||||
echo "--------------------->"
|
||||
echo "% Run script below to move users to reject ssh group";
|
||||
@@ -261,13 +306,13 @@ if [ "${OUTPUT_TARGET}" == "text" ]; then
|
||||
echo "% Run script below to move users to allow or forward ssh group";
|
||||
echo "";
|
||||
echo "For ALLOW:"
|
||||
echo "bin/unlock_user.sh -s allow ${lock_accounts}";
|
||||
echo "bin/unlock_user.sh -s allow ${unlock_accounts}";
|
||||
echo "";
|
||||
echo "For FORWARDONLY:"
|
||||
echo "bin/unlock_user.sh -s forward ${lock_accounts}";
|
||||
echo "bin/unlock_user.sh -s forward ${unlock_accounts}";
|
||||
fi;
|
||||
echo "[END] ===============>"
|
||||
elif [ "${OUTPUT_TARGET}" == "json" ]; then
|
||||
elif [ "${OUTPUT_TARGET}" = "json" ]; then
|
||||
# users
|
||||
echo "]";
|
||||
# overall
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
# * input file
|
||||
# user_list.txt
|
||||
# <ignored id>;<user name>;<group>[,sub group,sub group];<ssh access type>;[override password];[override hostname];[override ssh key type]
|
||||
# <ignored id>;<user name>;<group>[,sub group,sub group];<ssh access type>|<no login flag>;[override password];[override hostname];[override ssh key type]
|
||||
# lines with # are skipped
|
||||
# already created users are skipped
|
||||
# Mandatory: <ignored id>;<user name>;<group>;<ssh access type>
|
||||
# <ssh access type> can be
|
||||
# allow (full login access)
|
||||
# forward (forward/jump host only)
|
||||
# if in this column with pipe (|) the flag "no_login" is set then the default shell will change to "/sbin/nologin"
|
||||
# * output file
|
||||
# <date>;<target connect host name>;<hostname>;<username>;<password>;<ssh access type>
|
||||
# If already existing PEM key is used then <password> is [ALREADY SET]
|
||||
@@ -87,6 +88,13 @@ if [ ! -d "${HOME_FOLDER}" ]; then
|
||||
echo "Home folder location not found: ${HOME_FOLDER}";
|
||||
error=1;
|
||||
fi;
|
||||
# allow 10 to 39 length for password
|
||||
if [ ! -z "${PASSWORD_LENGTH}" ] && ! [[ "${PASSWORD_LENGTH}" =~ ^[13][0-9]$ ]]; then
|
||||
echo "Password length set error, can only be a value between 10 and 39";
|
||||
error=1;
|
||||
elif [ -z ${PASSWORD_LENGTH} ]; then
|
||||
PASSWORD_LENGTH=14;
|
||||
fi;
|
||||
# home dir error abort
|
||||
if [ $error -eq 1 ]; then
|
||||
exit;
|
||||
@@ -104,6 +112,10 @@ ssh_keytype='';
|
||||
# sshallow or sshforward
|
||||
ssh_group='';
|
||||
ssh_forward_ok=0;
|
||||
# login shells
|
||||
login_shell="/bin/bash";
|
||||
no_login_shell="/sbin/nologin";
|
||||
user_login_shell="";
|
||||
# detect ssh authorized_keys setting
|
||||
SSH_CENTRAL_AUTHORIZED_FILE_FOLDER='';
|
||||
SSH_AUTHORIZED_FILE='';
|
||||
@@ -195,8 +207,21 @@ while read i; do
|
||||
_group=$(echo "${i}" | cut -d ";" -f 3 | tr A-Z a-z | tr -d ' ');
|
||||
group=$(echo "${_group}" | cut -d "," -f 1);
|
||||
sub_group="";
|
||||
# POS 4: ssh access type
|
||||
ssh_access_type=$(echo "${i}" | cut -d ";" -f 4 | tr A-Z a-z | tr -d ' ');
|
||||
# POS 4: ssh access type and no login flag
|
||||
# no login flag
|
||||
no_login_flag="";
|
||||
# if there is a pipe, check, else ignore
|
||||
if echo "${i}" | cut -d ";" -f 4 | grep -q "|"; then
|
||||
no_login_flag=$(echo "${i}" | cut -d ";" -f 4 | cut -d "|" -f 2);
|
||||
fi;
|
||||
# anything set in no login shell flag, we set no login shell
|
||||
if [ -n "${no_login_flag}" ]; then
|
||||
user_login_shell="${no_login_shell}";
|
||||
else
|
||||
user_login_shell="${login_shell}";
|
||||
fi;
|
||||
# ssh access type
|
||||
ssh_access_type=$(echo "${i}" | cut -d ";" -f 4 | cut -d "|" -f 1 | tr A-Z a-z | tr -d ' ');
|
||||
# if not allow or forward, set to access
|
||||
if [ "${ssh_access_type}" != "allow" ] && [ "${ssh_access_type}" != "forward" ]; then
|
||||
echo "[!!] Not valid ssh access type ${ssh_access_type}, set to allow";
|
||||
@@ -214,7 +239,7 @@ while read i; do
|
||||
# check if "," inside and extract sub groups
|
||||
if [ -z "${_group##*,*}" ]; then
|
||||
sub_group=$(echo "${_group}" | cut -d "," -f 2-);
|
||||
sub_group_opt=" -G ${sub_group}";
|
||||
sub_group_opt=" -G ${ssh_group},${sub_group}";
|
||||
fi;
|
||||
# POS 5: do we have a password preset
|
||||
_password=$(echo "${i}" | cut -d ";" -f 5);
|
||||
@@ -292,9 +317,9 @@ while read i; do
|
||||
echo "++ Create '${username}:${group}(${sub_group})'";
|
||||
if [ ${TEST} -eq 0 ]; then
|
||||
# comment is user create time
|
||||
useradd -c `date +"%F"` -s /bin/bash -g ${group}${sub_group_opt} -d "${HOME_FOLDER}${username}" -m ${username};
|
||||
useradd -c `date +"%F"` -s "${user_login_shell}" -g ${group}${sub_group_opt} -d "${HOME_FOLDER}${username}" -m ${username};
|
||||
else
|
||||
echo "$> useradd -c `date +"%F"` -s /bin/bash -g ${group}${sub_group_opt} -d "${HOME_FOLDER}${username}" -m ${username}";
|
||||
echo "$> useradd -c `date +"%F"` -s "${user_login_shell}" -g ${group}${sub_group_opt} -d "${HOME_FOLDER}${username}" -m ${username}";
|
||||
fi;
|
||||
fi;
|
||||
# set the auth file
|
||||
@@ -309,7 +334,11 @@ while read i; do
|
||||
# Note we only create a password if we need it
|
||||
# password + store pwgen 10 1 -1
|
||||
if [ -z "${_password}" ]; then
|
||||
password=$(printf "%s" $(pwgen 14 1));
|
||||
password=$(printf "%s" $(pwgen ${PASSWORD_LENGTH} 1));
|
||||
elif [ "${_password}" = "SET_NO_PASSWORD" ]; then
|
||||
# set empty
|
||||
echo "* No password set";
|
||||
password="";
|
||||
else
|
||||
echo "! Override password set";
|
||||
password=${_password};
|
||||
@@ -410,14 +439,24 @@ done;
|
||||
if [ ${INFO} -eq 1 ]; then
|
||||
exit;
|
||||
fi;
|
||||
# check if there are any files in the SSH_KEYGEN_FOLDER, else skip zip file creation and file move
|
||||
has_pem_files=0;
|
||||
if (shopt -s nullglob dotglob; f=("${SSH_KEYGEN_FOLDER}"*".pem"*); ((${#f[@]}))); then
|
||||
has_pem_files=1;
|
||||
fi;
|
||||
# zip everything and remove data in ssh key folder, delete output file with passwords
|
||||
if [ ${TEST} -eq 0 ]; then
|
||||
zip -r \
|
||||
"${ROOT_FOLDER}${output_zip_folder}${output_zip}" \
|
||||
"${input_file}" \
|
||||
"${output_file}" \
|
||||
"${SSH_KEYGEN_FOLDER}" \
|
||||
-x\*.gitignore;
|
||||
if [ "${has_pem_files}" -eq 1 ]; then
|
||||
zip -r \
|
||||
"${ROOT_FOLDER}${output_zip_folder}${output_zip}" \
|
||||
"${input_file}" \
|
||||
"${output_file}" \
|
||||
"${SSH_KEYGEN_FOLDER}" \
|
||||
-x\*.gitignore;
|
||||
echo "Download: ${ROOT_FOLDER}${output_zip_folder}${output_zip}";
|
||||
else
|
||||
echo "Skip ZIP file creation, no pem files";
|
||||
fi;
|
||||
else
|
||||
echo "zip -r \\"
|
||||
echo "${ROOT_FOLDER}${output_zip_folder}${output_zip} \\"
|
||||
@@ -425,15 +464,19 @@ else
|
||||
echo "${output_file} \\"
|
||||
echo "${SSH_KEYGEN_FOLDER} \\"
|
||||
echo "-x\*.gitignore;"
|
||||
echo "Download: ${ROOT_FOLDER}${output_zip_folder}${output_zip}";
|
||||
fi;
|
||||
echo "Download: ${ROOT_FOLDER}${output_zip_folder}${output_zip}";
|
||||
# cleam up user log file and ssh keys
|
||||
if [ ${TEST} -eq 0 ]; then
|
||||
# move pub to created folders
|
||||
mv "${ROOT_FOLDER}${SSH_KEYGEN_FOLDER}"*.pub "${ROOT_FOLDER}${SSH_KEYGEN_FOLDER_CREATED_PUB}";
|
||||
# delete the rest
|
||||
rm "${ROOT_FOLDER}${output_file}";
|
||||
rm "${ROOT_FOLDER}${SSH_KEYGEN_FOLDER}"*;
|
||||
if [ "${has_pem_files}" -eq 1 ]; then
|
||||
# move pub to created folders
|
||||
mv "${ROOT_FOLDER}${SSH_KEYGEN_FOLDER}"*.pub "${ROOT_FOLDER}${SSH_KEYGEN_FOLDER_CREATED_PUB}";
|
||||
# delete the rest
|
||||
rm "${ROOT_FOLDER}${output_file}";
|
||||
rm "${ROOT_FOLDER}${SSH_KEYGEN_FOLDER}"*;
|
||||
else
|
||||
echo "Skip pub file move and cleanup, no pem files";
|
||||
fi;
|
||||
else
|
||||
echo "$> mv ${ROOT_FOLDER}${SSH_KEYGEN_FOLDER}*.pub ${ROOT_FOLDER}${SSH_KEYGEN_FOLDER_CREATED_PUB};";
|
||||
echo "$> rm ${ROOT_FOLDER}${output_file}";
|
||||
|
||||
@@ -39,7 +39,7 @@ if [ -z $(cat /etc/group | grep "${ssh_reject_group}:") ]; then
|
||||
exit;
|
||||
fi;
|
||||
ssh_allow_group="sshallow";
|
||||
ssh_forward_group="sshfoward";
|
||||
ssh_forward_group="sshforward";
|
||||
user_group_tpl="gpasswd -d %s %s\ngpasswd -a %s %s\n";
|
||||
|
||||
echo "--------------------->"
|
||||
|
||||
@@ -53,7 +53,7 @@ if [ -z $(cat /etc/group | grep "${ssh_reject_group}:") ]; then
|
||||
exit;
|
||||
fi;
|
||||
ssh_allow_group="sshallow";
|
||||
ssh_forward_group="sshfoward";
|
||||
ssh_forward_group="sshforward";
|
||||
user_group_tpl="gpasswd -d %s %s\ngpasswd -a %s %s\n";
|
||||
|
||||
echo "--------------------->"
|
||||
|
||||
@@ -1 +1 @@
|
||||
#user_id;user_name;group,subgroup;ssh access type;override password;override hostname;override ssh type
|
||||
#user_id;user_name;group,subgroup;ssh access type|no login flag;override password;override hostname;override ssh type
|
||||
|
||||
Reference in New Issue
Block a user