Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43ef147de6 |
@@ -247,9 +247,9 @@ while read i; do
|
|||||||
echo "++ Create '${username}:${group}(${sub_group})'";
|
echo "++ Create '${username}:${group}(${sub_group})'";
|
||||||
if [ ${TEST} -eq 0 ]; then
|
if [ ${TEST} -eq 0 ]; then
|
||||||
# comment is user create time
|
# comment is user create time
|
||||||
useradd -c `date +"%F"` -s /bin/bash -g ${group}${sub_group_opt} -d "${HOME_FOLDER}" -m ${username};
|
useradd -c `date +"%F"` -s /bin/bash -g ${group}${sub_group_opt} -d "${HOME_FOLDER}${username}" -m ${username};
|
||||||
else
|
else
|
||||||
echo "$> useradd -c `date +"%F"` -s /bin/bash -g ${group}${sub_group_opt} -d "${HOME_FOLDER}" -m ${username}";
|
echo "$> useradd -c `date +"%F"` -s /bin/bash -g ${group}${sub_group_opt} -d "${HOME_FOLDER}${username}" -m ${username}";
|
||||||
fi;
|
fi;
|
||||||
fi;
|
fi;
|
||||||
# set the auth file
|
# set the auth file
|
||||||
@@ -281,7 +281,10 @@ while read i; do
|
|||||||
echo "$> ssh-keygen -t ${ssh_keytype} -f ${ssh_keyfile} -C ${hostname}: ${username}@${group} -a 100 -N ${password}";
|
echo "$> ssh-keygen -t ${ssh_keytype} -f ${ssh_keyfile} -C ${hostname}: ${username}@${group} -a 100 -N ${password}";
|
||||||
fi;
|
fi;
|
||||||
else
|
else
|
||||||
|
found='';
|
||||||
|
if [ -f "${SSH_AUTHORIZED_FILE}" ]; then
|
||||||
found=$(grep "$(cat ${ssh_keyfile_check_pub})" ${SSH_AUTHORIZED_FILE});
|
found=$(grep "$(cat ${ssh_keyfile_check_pub})" ${SSH_AUTHORIZED_FILE});
|
||||||
|
fi;
|
||||||
if [ ! -z "${found}" ]; then
|
if [ ! -z "${found}" ]; then
|
||||||
skip_ssh=1;
|
skip_ssh=1;
|
||||||
echo "-- Skip SSH Key creation: ${ssh_keygen_id}.pub";
|
echo "-- Skip SSH Key creation: ${ssh_keygen_id}.pub";
|
||||||
@@ -303,7 +306,7 @@ while read i; do
|
|||||||
echo $(date +"%F %T")";"${host}";"${_hostname}";"${username}";"${password}";"${ssh_allow_type} >> ${create_output_file};
|
echo $(date +"%F %T")";"${host}";"${_hostname}";"${username}";"${password}";"${ssh_allow_type} >> ${create_output_file};
|
||||||
# create folder only if we do not have central
|
# create folder only if we do not have central
|
||||||
# create the SSH foler and authorized access file with correct permissions
|
# create the SSH foler and authorized access file with correct permissions
|
||||||
if [ ! -z "${SSH_CENTRAL_AUTHORIZED_FILE_FOLDER}" ]; then
|
if [ -z "${SSH_CENTRAL_AUTHORIZED_FILE_FOLDER}" ]; then
|
||||||
echo " > Create .ssh folder";
|
echo " > Create .ssh folder";
|
||||||
if [ ${TEST} -eq 0 ]; then
|
if [ ${TEST} -eq 0 ]; then
|
||||||
mkdir ${HOME_FOLDER}${username}/.ssh/;
|
mkdir ${HOME_FOLDER}${username}/.ssh/;
|
||||||
@@ -314,12 +317,18 @@ while read i; do
|
|||||||
# add
|
# add
|
||||||
echo " > Add public into authorized_keys file";
|
echo " > Add public into authorized_keys file";
|
||||||
if [ ${TEST} -eq 0 ]; then
|
if [ ${TEST} -eq 0 ]; then
|
||||||
if [ ! -z "${SSH_CENTRAL_AUTHORIZED_FILE_FOLDER}" ]; then
|
if
|
||||||
|
[ ! -z "${SSH_CENTRAL_AUTHORIZED_FILE_FOLDER}" ] &&
|
||||||
|
[ -f "${SSH_AUTHORIZED_FILE}" ];
|
||||||
|
then
|
||||||
chattr -i ${SSH_AUTHORIZED_FILE};
|
chattr -i ${SSH_AUTHORIZED_FILE};
|
||||||
fi;
|
fi;
|
||||||
cat "${ssh_keyfile_pub}" > ${SSH_AUTHORIZED_FILE};
|
cat "${ssh_keyfile_pub}" > ${SSH_AUTHORIZED_FILE};
|
||||||
else
|
else
|
||||||
if [ ! -z "${SSH_CENTRAL_AUTHORIZED_FILE_FOLDER}" ]; then
|
if
|
||||||
|
[ ! -z "${SSH_CENTRAL_AUTHORIZED_FILE_FOLDER}" ] &&
|
||||||
|
[ -f "${SSH_AUTHORIZED_FILE}" ];
|
||||||
|
then
|
||||||
echo "$> chattr -i ${SSH_AUTHORIZED_FILE}";
|
echo "$> chattr -i ${SSH_AUTHORIZED_FILE}";
|
||||||
fi;
|
fi;
|
||||||
echo "$> cat ${ssh_keyfile_pub} > ${SSH_AUTHORIZED_FILE}";
|
echo "$> cat ${ssh_keyfile_pub} > ${SSH_AUTHORIZED_FILE}";
|
||||||
|
|||||||
Reference in New Issue
Block a user