if [ -n "${SSH_CLIENT}" ]; then
NETWORK_A_CLASS="${SSH_CLIENT%%.*}."
# non-interactive mode => serial
# interactive mode (login shell) => pty
contype="$(/sbin/consoletype 2> /dev/null)"
if [ -z "${LOGIN_ACCESS}" ]; then
case "${NETWORK_A_CLASS}" in
# Allow non-interactive shell from private network range
# If you want to allow only interactive shell
# [ "${contype}" = "pty" ] && LOGIN_ACCESS="yes"
# If you want to allow both interactive and non-interactive shell
[ "${contype}" != "pty" ] && LOGIN_ACCESS="yes"
if [ -z "${LOGIN_ACCESS}" ]; then
# ssh_client format: IP_ADDRESS:CONNECT_PORT
ssh_client=$(echo ${SSH_CLIENT} | /bin/awk '{print $1":"$3'})
NETWORK_B_CLASS=$(echo ${ssh_client} | /bin/sed -e 's/\(\([0-9]\+\.\)\{2\}\).*/\1/g' 2> /dev/null)
NETWORK_C_CLASS=$(echo ${ssh_client} | /bin/sed -e 's/\(\([0-9]\+\.\)\{3\}\).*/\1/g' 2> /dev/null)
case "${NETWORK_B_CLASS}" in
# Allow non-interactive shell from private network range
[ "${contype}" != "pty" ] && LOGIN_ACCESS="yes"
if [ -z "${LOGIN_ACCESS}" ]; then
case "${NETWORK_C_CLASS}" in
# [ "${contype}" != "pty" ] && LOGIN_ACCESS="yes"
# [ "${contype}" != "pty" ] && LOGIN_ACCESS="yes"
# [ "${contype}" != "pty" ] && LOGIN_ACCESS="yes"
[ -z "$LOGIN_ACCESS" ] && \
echo -en "* \\033[1;31mNotice:\\033[0;39m" && \
echo " You can't access root privileges with remote access!" && \