Add message if key was alrady added or removed
This commit is contained in:
@@ -99,6 +99,8 @@ remove_ssh_key() {
|
||||
sed -i "/${pub_key_escaped}/d" "${AUTH_KEY_FILE}";
|
||||
${RMV_CHMOD_UW} "${AUTH_KEY_FILE}";
|
||||
${ADD_CHATTR_I} "${AUTH_KEY_FILE}";
|
||||
else
|
||||
echo "[!] Already removed";
|
||||
fi;
|
||||
EOF
|
||||
);
|
||||
|
||||
@@ -163,6 +163,8 @@ add_ssh_key() {
|
||||
echo "${pub_key_write}" >> "${AUTH_KEY_FILE}" || exit 1;
|
||||
${RMV_CHMOD_UW} "${AUTH_KEY_FILE}";
|
||||
${ADD_CHATTR_I} "${AUTH_KEY_FILE}";
|
||||
else
|
||||
echo "[!] Already added";
|
||||
fi;
|
||||
EOF
|
||||
);
|
||||
|
||||
4
bin/user-add-ssh-key.sh
Normal file → Executable file
4
bin/user-add-ssh-key.sh
Normal file → Executable file
@@ -127,6 +127,8 @@ add_ssh_key() {
|
||||
echo "${pub_key_write}" >> "${AUTH_KEY_FILE}" || exit 1;
|
||||
${RMV_CHMOD_UW} "${AUTH_KEY_FILE}";
|
||||
${ADD_CHATTR_I} "${AUTH_KEY_FILE}";
|
||||
else
|
||||
echo "[!] Already added";
|
||||
fi;
|
||||
EOF
|
||||
);
|
||||
@@ -171,7 +173,7 @@ while read -r line; do
|
||||
continue;
|
||||
fi
|
||||
|
||||
echo "[+] Add new public key '${SSH_KEY_PUB_FILE}' to: ${username}@${hostname}";
|
||||
echo "[+] Add new public key '${USER_PUBLIC_KEY}' to: ${username}@${hostname}";
|
||||
|
||||
# flags: (not used at the moment)
|
||||
# Possible: U (add to .ssh/authorized_keys)
|
||||
|
||||
4
bin/user-remove-ssh-key.sh
Normal file → Executable file
4
bin/user-remove-ssh-key.sh
Normal file → Executable file
@@ -109,6 +109,8 @@ remove_ssh_key() {
|
||||
sed -i "/${pub_key_escaped}/d" "${AUTH_KEY_FILE}";
|
||||
${RMV_CHMOD_UW} "${AUTH_KEY_FILE}";
|
||||
${ADD_CHATTR_I} "${AUTH_KEY_FILE}";
|
||||
else
|
||||
echo "[!] Already removed";
|
||||
fi;
|
||||
EOF
|
||||
);
|
||||
@@ -147,7 +149,7 @@ while read -r line; do
|
||||
continue;
|
||||
fi
|
||||
|
||||
echo "[-] Remove public key '${SSH_KEY_PUB_FILE}' from: ${username}@${hostname}";
|
||||
echo "[-] Remove public key '${USER_PUBLIC_KEY}' from: ${username}@${hostname}";
|
||||
|
||||
uninstall_ssh_key "${hostname}" "${username}" "${SSH_KEY_PUB_FILE}" "/etc/ssh/authorized_keys/${username}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user